Home > Web Front-end > JS Tutorial > body text

The JavaScript method getUTCDate() returns a day of the month (UTC) based on Universal Time

黄舟
Release: 2017-11-06 13:13:43
Original
2345 people have browsed it

Definition and Usage

The getUTCDate() method returns the day of the month (UTC) based on Universal Time.

Syntax

dateObject.getUTCDate()
Copy after login

Return value

dateObject When expressed in universal time, returns the day of the month (a value from 1 to 31).

Tips and Comments:

Comments: This method is always used in conjunction with a Date object.

Tip: For more information about Universal Coordinated Time (UTC), please refer to Baidu Encyclopedia.

Example

Example 1

In this example, we will output the current day of this appointment according to UTC:

<script type="text/javascript">

var d = new Date()
document.write(d.getUTCDate())

</script>
Copy after login

Output:

6
Copy after login

Example 2

We define a variable with a specific date here, and then output the day of the month in the variable according to UTC:

<script type="text/javascript">

var birthday = new Date("July 21, 1983 01:15:00")
document.write(birthday.getUTCDate())

</script>
Copy after login

Output:

21
Copy after login

JavaScript Date.getUTCDate() method returns the day of the month on the specified date according to universal time. The value returned by getUTCDate is an integer between 1 and 31.

Example:

<html>
<head>
<title>JavaScript getUTCDate Method</title>
</head>
<body>
<script type="text/javascript">
  var dt = new Date( "December 25, 1995 23:15:20" );
  document.write("getUTCDate() : " + dt.getUTCDate() ); 
</script>
</body>
</html>
Copy after login

This will produce the following results for India time zone:

getUTCDate() : 25
Copy after login

The above is the detailed content of The JavaScript method getUTCDate() returns a day of the month (UTC) based on Universal Time. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template