Latest web development tutorials

JavaScript UTC () method

Date Object Reference JavaScript Date Object

Examples

It returns the number of milliseconds January 1, 1970 to a specified date:

var d=Date.UTC(2012,02,30);

d output:


try it"

Definition and Usage

UTC () method returns the number of milliseconds January 1, 1970 to the date specified in accordance with world

Tip: Coordinated Universal Time, also known as the unified world time, Universal Time, Coordinated Universal Time, abbreviated UTC (Universal Coordinated Time).

Note: UTC time and GMT (Greenwich Mean Time) the same.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

UTC () All major browsers support UTC () method.


grammar

Date.UTC( year , month , day , hours , minutes , seconds , millisec )

Parameter Values

parameter description
year Required. Four digits indicate the year.
month Required. The month integer between 0 and 11.
day Required. Integer representation of the date, ranging from 1 to 31.
hours Optional. H represents an integer between 0 to 23.
minutes Optional. The minute integer between 0 and 59.
seconds Optional. S represents an integer between 0 to 59.
ms Optional. Integer representing milliseconds between 0 and 999.

return value

类型 描述
Number 返回指定的时间距 GMT 时间 1970 年 1 月 1 日午夜的毫秒数。

technical details

JavaScript version: 1.0


More examples

Examples

Local time into UTC time:

var d=new Date(Date.UTC(2012,02,30));

d output:


try it"


Date Object Reference JavaScript Date Object