Redo JS Virtuoso four bullets: Date

Source: Internet
Author: User
1 Date principle

The date type represents time, and JS uses UTC international coordination time, starting from January 1, 1971 0 minutes 0 seconds 0 microseconds, elapsed milliseconds to represent time, such as a year's time calculation

1 points: 1000*60;

1 Hours: 1000 (ms) *60*60;

1 year: 1000*60*60*24*365=31 536 000 000, if 1000 years is added directly 000, this is JS in the time of the expression principle

2 Conversion

Resolves a string to a time

Date.parse (): The function will parse a date similar to: ' 6/23/2005 ', if it does not successfully return Nan;

Then using the var date=new date (), the constructor constructs a new Date object, and you can actually use the date string directly as the dates constructor parameter: var date=new date (' 2/19/2002 ');

In fact, the native JS on time conversion and formatting ability are very weak, their main calculations are in milliseconds, the general format and conversion are implemented through a number of CDN Tool Library, of course, they are by the date of the addition of the prototype method to achieve

For example, date.prototype.formart=function (value) {return '};

3 The methods provided

These methods are the basis of date formatting

Redo JS Virtuoso four bullets: Date

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.