Javascript date utc

Source: Internet
Author: User

Javascript date utc

Recently, when using highstock for statistical analysis, the time object in the json object requires the utc format, and the millisecond is used to implement the function of dragging the number axis. Here we sort out the functions for UTC conversion.

JavaScript Date. UTC () function

Date. UTC () -- returns the number of milliseconds (timestamp) between the date object and the World Standard Time (UTC) midnight, January 1, January 1, 1970)

UTC function syntax
Date. UTC (year, month, day );
Date. UTC (year, month, day, hours );
Date. UTC (year, month, day, hours, minutes );
Date. UTC (year, month, day, hours, minutes, seconds );
Date. UTC (year, month, day, hours, minutes, seconds, microseconds );

UTC function parameters
Year-the year of the date object, which is a four-digit year value.
An integer between month and 0-11, used as the month of the date object.
The integer between day-1-31 as the number of days of the date object.
An integer between hours-0 (midnight) and 23, used as the hour of the date object
Minutes-an integer between 0 and 59, used as the minute count of the date object
The integer between seconds-0-59, used as the number of seconds of the date object.
Microseconds-an integer between 0 and, expressed as the number of milliseconds of the date object.

UTC function return value
Returns the number of milliseconds (timestamp) between the date object and midnight on January 1, January 1, 1970)

UTC description
This function is a static function and should be called directly.
You can obtain a log from both the UTC method and the Date object constructor. The difference between them is that the UTC method is assumed to be UTC, And the Date object constructor is assumed to be local time.

UTC function example
Document. write (Date. UTC (2014, 01, 01 ));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.