JavaScript Date UTC() method
- Föregående sida toUTCString()
- Nästa sida valueOf()
- Gå tillbaka till föregående nivå JavaScript Date referenshandbok
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
Returns 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 number of the year, 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 0. Represents the integer part of hours The expected value is 0-23, but other values are allowed:
|
min |
Optional. Default 0. Represents the integer part of minutes The expected value is 0-59, but other values are allowed:
|
sec |
Optional. Default 0. Represents the integer part of seconds The expected value is 0-59, but other values are allowed:
|
millisec |
Optional. Default 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 |
Webbläsarstöd
Metoder | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
UTC() | Stöd | Stöd | Stöd | Stöd | Stöd |
- Föregående sida toUTCString()
- Nästa sida valueOf()
- Gå tillbaka till föregående nivå JavaScript Date referenshandbok