JavaScript reference type (ii)

Source: Internet
Author: User

Date type

The date type in JavaScript is built on the Java.util.Date class in Java and uses UTC time to save the data to 285,616 years before or after January 1, 1970

Create a Date object that uses the new keyword with a constructor declaration (the date object is also a reference type), and the new object automatically gets the current date and time without passing any arguments to the constructor, as follows:

var nowtime=New//Ed 13:31:12 gmt+0800 (China Standard Time)

There are two ways to create a Date object based on a specific date and time: Date.parse () and DATE.UTC ()

Date.parse (): Parses a string that contains a date and returns the number of milliseconds between that date and midnight January 1, 1970.

        var datestring= "November 1, 1997 10:15 AM"        var mSec = date.parse (datestring);        document.write (MSEC);         // output:878404500000

The Date.parse () function returns an integer value that represents the number of milliseconds between the date provided in Dateval and the midnight of January 1, 1970.

JavaScript reference type (ii)

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.