5 ways to initialize JS data date

Source: Internet
Author: User

  This article introduces the next JS data date initialization of 5 commonly used methods, interested friends can refer to the following

Create a Date object:  code as follows: Var objdate=new date ([arguments list]);    parameter in the form of the following 5:    1) New Date ("Month Dd,y YYY Hh:mm:ss ");  2) New Date (" Month dd,yyyy ");  3) New Date (YYYY,MTH,DD,HH,MM,SS);    In the program I used the third initialization method, always show the format of the parameter is not correct, carefully looked at it must be integral type, I passed the string     4) New Date (YYYY,MTH,DD);  5) New Date (MS) ;    Note the last form, which represents the number of milliseconds to create and the difference between GMT time January 1, 1970. The meanings of various functions are as follows:    month: month names in English, from January to december    MTH: Month by integer, from (January) to 11 (December)     DD: Represents the day ordinal of one months, from 1 to 31    YYYY: four-digit year     HH: Hours, from 0 (midnight) to 23 (11 o'clock in the evening)     mm: minutes, integers from 0 to 59   & nbsp SS: seconds, integers from 0 to 59     MS: milliseconds, for integers greater than or equal to 0     such as:    code as follows: New Date ("January 12,2006 22:19:35"); nbsp   New Date ("January 12,2006");    new Date (2006,0,12,22,19,35);    new Date (2006,0,12);  & nbsp The new Date (1137075575000);    The various creation forms above represent the day of January 12, 2006.    

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.