JavaScript UTC()Method
Example
Return the number of milliseconds from January 1, 1970 to the specified date:
var d=Date.UTC(2012,02,30);
dOutput:
Try it Yourself »
Definition and Usage
The UTC() method returns the number of milliseconds from January 1, 1970 to the specified date according to universal time.
Tip:Coordinated Universal Time, also known as Universal Coordinated Time, World Standard Time, International Coordinated Time, abbreviated as UTC (Universal Coordinated Time).
Note:UTC time is the same as GMT (Greenwich Mean Time).
Browser Support
![]()
![]()
![]()
![]()
![]()
UTC() All major browsers support the UTC() method.
Syntax
Date.UTC(year,month,day,hours,minutes,seconds,millisec)
Parameter Values
| Parameter | Description |
|---|---|
| year | Required. A four-digit number representing the year. |
| month | Required. An integer representing the month, between 0 and 11. |
| day | Required. An integer representing the day, between 1 and 31. |
| hours | Optional. An integer representing the hour, between 0 and 23. |
| minutes | Optional. An integer representing the minutes, between 0 and 59. |
| seconds | Optional. An integer representing the seconds, between 0 and 59. |
| ms | Optional. An integer representing the milliseconds, between 0 and 999. |
Return Value
| Type | Description |
|---|---|
| Number | Returns the number of milliseconds from the specified time to midnight of January 1, 1970 (GMT). |
Technical Details
| JavaScript Version: | 1.0 |
|---|
More Examples
Example
Convert local time to UTC time:
var d=new Date(Date.UTC(2012,02,30));
dOutput:
Try it Yourself »
Other Extensions
JavaScript Date Object