JavaScript Date.UTC() Method
JavaScript Date.UTC() Method
The Date.UTC
method returns a number representing the number of milliseconds for the given date since January 1, 1970, 00:00:00, UTC.
It takes comma-delimited date and time parameters.
Note: If a parameter is outside of the expected range, the UTC() method updates the other parameters to accommodate the value. For example, if 13 is used for month, the year will be incremented by 1 (year + 1) and 1 will be used for the month.
Example
Syntax
Parameter Values
Value | Type | Explanation |
---|---|---|
year | Required | A full year. |
month | Optional | An integer between 0 (January) and 11 (December) representing the month. |
day | Optional | An integer between 1 and 31 representing the day of the month. If omitted, defaults to 1. |
hour | Optional | An integer between 0 and 23 representing the hours. If omitted, defaults to 0. |
minute | Optional | An integer between 0 and 59 representing the minutes. If omitted, defaults to 0. |
second | Optional | An integer between 0 and 59 representing the seconds. If omitted, defaults to 0. |
millisecond | Optional | An integer between 0 and 999 representing the milliseconds. If omitted, defaults to 0. |
Return Value
Value | Explanation |
---|---|
Number | Returns a number representing the number of milliseconds for the given date since January 1, 1970, 00:00:00, UTC. |
Date.UTC() as Argument
In the following example, a Date object with the arguments treated as UTC instead of local.
Example
Reminder
Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in JavaScript.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.