Fifth reference type > Data type

Source: Internet
Author: User
Tags month name

Data type

The data type saves the date using the number of milliseconds since UTC (International coordination Time) January 1, 1970 midnight.

Create a Date object:

var New Date (); Console.log (now); // Sun June 17:43:32 gmt+0800 (China Standard Time)
Methods for creating Date objects

date.parse (): accepts a string argument that represents a date, EC5 does not define the date appropriate for the support, and the behavior is realistic.

Browser Settings for United States:

"Month/day/year" 6/13/2016

"English month name Day, year" January 13,2016

English day of the week English month name: minutes: Seconds time zone Tue 2004 00:00:00 GTM-0700

var New Date (Date.parse ("May, 2004")); Console.log (somedate); // Tue 2004 00:00:00 gmt+0800 (China Standard Time)

Returns Nan if the passed-in string cannot represent a date;

DATE.UTC ():

var New Date (DATE.UTC (2005, 4, 5, +,)); Console.log (time); // Fri 2005 01:55:55 gmt+0800 (China Standard Time)
Month based on 0 start

Date constructor:

The date and time are created based on the local time zone.

var New Date (0, 0); Console.log (sometime); //   Fri Dec 1999 00:00:00 gmt+0800 (China Standard Time)
var New Date (2005, 4, 5, N, +); Console.log (sometime); // Thu 2005 17:55:55 gmt+0800 (China Standard Time)
Methods of Inheritance

toLocaleString () and ToString ():

Different browsers behave differently. useful when debugging code;

ValueOf (): Returns the millisecond representation of the date. Can be used to compare date values.

var New Date (0, 1); var New Date (1, 1>< date2); // false // true

Fifth reference type > Data type

Related Article

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.