English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Date.UTC() method gets a date and returns the number of milliseconds since1970 years1Month1Milliseconds since midnight of the day.
The Date.UTC() method accepts the same parameters as the Date constructor, but treats them as UTC.
It returns the number of milliseconds since1970 years1Month1Milliseconds since UTC 00:00:00 of the day.
World Standard Time (UTC) is the time set by the world time standard.
Since UTC() is a static method of Date, you should always use it as Date.UTC().
Date.UTC(year, month, day, hours, minutes, seconds, millisec)
var d = Date.UTC(2016, 04, 20);Test and see‹/›
All browsers fully support the UTC() method:
Method | |||||
UTC() | Is | Is | Is | Is | Is |
Parameter | Description |
---|---|
year | (Required) The four-digit representation of the year |
month | (Required) 0 to11representing the month. The integer must be between |
day | (Optional) Between1to31representing the day of the month. If omitted, it defaults to1 |
hours | (Optional) Integer between23representing hours. If omitted, it defaults to 0 |
minutes | (Optional) Integer between59representing minutes. If omitted, it defaults to 0 |
seconds | (Optional) Integer between59representing seconds. If omitted, it defaults to 0 |
millisec | (Optional) Integer between999The integer between the two dates, representing milliseconds. If omitted, it defaults to 0 |
Return Value: | Represents1970 years1Month1The number of milliseconds since the start of the given date |
---|---|
JavaScript Version: | ECMAScript 1 |
This example creates a date object using UTC time instead of local time:
var d = new Date(Date.UTC(2016, 04, 20));Test and see‹/›