JavaScript Date getUTCDate() method

The getUTCDate method in JavaScript retrieves the day of the month for a given date according to Coordinated Universal Time (UTC).

Syntax

The syntax for the getUTCDate method is expressed as follows:

Example

dateObj.getUTCDate()

Return

A numerical value ranging from 1 to 31 that signifies the day within the given date.

JavaScript Date getUTCDate method example

In this section, we will explore the getUTCDate method by examining a range of examples.

Example 1

Let’s examine an example that demonstrates how to display the current date in accordance with Coordinated Universal Time (UTC).

Example

<script>	

var date=new Date();	

document.writeln("Today's day: "+date.getUTCDate());

</script>

Output:

Output

Today's day: 8

Example 2

Let's examine an example that demonstrates how to extract and display the day from a specified date in accordance with Coordinated Universal Time (UTC).

Example

<script>

var date1=new Date("August 15, 1947 20:22:10 GMT+12:00");

var date2=new Date("August 15, 1947 20:22:10 GMT-12:00");

document.writeln("Date value1 : "+date1.getUTCDate()+"<br>");

document.writeln("Date value2 : "+date2.getUTCDate());

</script>

Output:

Output

Date value1 : 15

Date value2 : 16

Input Required

This code uses input(). Please provide values below: