JavaScript Date UTC() method
- Vorherige Seite toUTCString()
- Nächste Seite valueOf()
- Zurück zur übergeordneten Ebene JavaScript Date Referenzhandbuch
Definition and usage
UTC()
The method returns the milliseconds between the specified date and midnight of 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 of 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. Expected values are 0-11, but other values are allowed:
|
day |
Optional. Integer representing the day of the month. Expected values are 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. Expected values are 0-23, but other values are allowed:
|
min |
Optional. Default is 0. Represents the integer part of minutes. Expected values are 0-59, but other values are allowed:
|
sec |
Optional. Default is 0. Represents the integer part of seconds Expected values are 0-59, but other values are allowed:
|
millisec |
Optional. Default is 0. Represents the integer part of milliseconds Expected values are 0-999, but other values are allowed:
|
Technical details
Return value: | Numerical value representing the milliseconds between the specified date and time and midnight of January 1, 1970. |
---|---|
JavaScript Version: | ECMAScript 1 |
Browserkompatibilität
Methode | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
UTC() | Unterstützung | Unterstützung | Unterstützung | Unterstützung | Unterstützung |
- Vorherige Seite toUTCString()
- Nächste Seite valueOf()
- Zurück zur übergeordneten Ebene JavaScript Date Referenzhandbuch