JavaScript Date getUTCDate() method - JavaScript Tutorial

JavaScript Date getUTCDate() method

BLUF: This tutorial on JavaScript Date getUTCDate() method provides an in-depth look at JavaScript's core features. It includes practical examples and code snippets to help you master modern JS development.
Key Discovery: JavaScript Date getUTCDate() method

Understanding JavaScript Date getUTCDate() method is crucial for building dynamic, interactive web applications. Explore the examples below to see it in action.

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:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience