JavaScript Date UTC() method
- Previous Page toUTCString()
- Next Page valueOf()
- Go to the Previous Level JavaScript Date Reference Manual
Definition and usage
UTC()
The method returns the milliseconds between the specified date and midnight on January 1, 1970 based on world time.
Tip:Coordinated Universal Time (UTC) is the time set by the world time standard.
Note:UTC time is the same as GMT time (Greenwich Mean Time).
Example
Example 1
Return the milliseconds between the specified date and midnight on January 1, 1970:
var d = Date.UTC(2012, 02, 30);
Example 2
Create a date object using UTC time instead of local time:
var d = new Date(Date.UTC(2012, 02, 30));
Syntax
Date.UTC(year, month, day, hours, minutes, seconds, millisec)
Parameter value
Parameter | Description |
---|---|
year | Required. Represents the four-digit year value, allowing negative values. |
month |
Required. Represents the integer of the month. The expected value is 0-11, but other values are allowed:
|
day |
Optional. Integer, representing the day of the month. The expected value is 1-31, but other values are allowed:
If a month has 31 days:
If a month has 30 days:
|
hour |
Optional. Default is 0. Represents the integer part of hours. The expected value is 0-23, but other values are allowed:
|
min |
Optional. Default is 0. Represents the integer part of minutes. The expected value is 0-59, but other values are allowed:
|
sec |
Optional. Default is 0. Represents the integer part of seconds The expected value is 0-59, but other values are allowed:
|
millisec |
Optional. Default is 0. Represents the integer part of milliseconds The expected value is 0-999, but other values are allowed:
|
Technical details
Return value: | A number representing the milliseconds between the specified date and time and midnight on January 1, 1970. |
---|---|
JavaScript version: | ECMAScript 1 |
Browser Support
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
UTC() | Support | Support | Support | Support | Support |
- Previous Page toUTCString()
- Next Page valueOf()
- Go to the Previous Level JavaScript Date Reference Manual