Returns the number of milliseconds in a Date object since January 1, 1970, 00:00:00, universal time.
Method of Date
Syntax
Date.UTC( year, month, day, hrs, min, sec, ms )
Parameters
Parameter | Description |
---|---|
year | A year after 1900. |
month | An integer between 0 and 11 representing the month. |
date | An integer between 1 and 31 representing the day of the month. |
hrs | An integer between 0 and 23 representing the hours. |
min | An integer between 0 and 59 representing the minutes. |
sec | An integer between 0 and 59 representing the seconds. |
ms | An integer between 0 and 999 representing the milliseconds. |
Description
UTC takes comma-delimited date parameters and returns the number of milliseconds between January 1, 1970, 00:00:00, universal time and the time you specified.
You should specify a full year for the year; for example, 1998. If a year between 0 and 99 is specified, the method converts the year to a year in the 20th century (1900 + year); for example, if you specify 95, the year 1995 is used.
The UTC method differs from the Date constructor in two ways.
Date.UTC uses universal time instead of the local time.
Date.UTC returns a time value as a number instead of creating a Date object.
If a parameter you specify is outside of the expected range, the UTC method updates the other parameters to allow for your number. For example, if you use 15 for month, the year will be incremented by 1 (year + 1), and 3 will be used for the month.
Because UTC is a static method of Date, you always use it as Date.UTC(), rather than as a method of a Date object you created.
Examples
The following statement creates a Date object using GMT instead of local time: