JavaScript Date Full Solution

Source: Internet
Author: User
Tags time and date

Date constructor new Date () | Date ()

No parameter defaults to the time of the system's current time zone, as a result:

Sat Apr11 16:42:09 gmt+0800 (China Standard Time)

The time it takes to generate a representation of the current system without new can be generated, and date itself is a method.

New Date (milliseconds)

This millisecond parameter is the time elapsed from 1970-01-01 00:00:00 to now.

New Date (datestring)

The ECMA is not specified, so only the formats currently supported are listed.

ISO format time

The most notable feature of the time in ISO format is the use of hyphens (-) between months and days, dates and times may have a letter (T), and there may be a letter Z or jet lag after the time.

T has no meaning, just means that the date and time are split here, and Z indicates that the time is UTC time.

Class ISO format

Results

2015-1

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

2015-1-1

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

2015-1 00:00:00+04:00

Thu Jan: 00:00 gmt+0800 (China Standard Time)

2015-1-1 00:00:00+04:00

Thu Jan: 00:00 gmt+0800 (China Standard Time)

2015-1-1 00:00:00z+08:00

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

2015-01-01 00:00

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

2015-01-01 00:00:00

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

2015-01-01 00:00:00+08:00

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

2015-01-01 00:00:00z

Thu Jan: 00:00 gmt+0800 (China Standard Time)

2015-01-01 00:00:00z+08:00

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

ISO standard format

Results

2015-01

Thu Jan: 00:00 gmt+0800 (China Standard Time)

2015-01-01

Thu Jan: 00:00 gmt+0800 (China Standard Time)

2015-01-01t00:00:00

Thu Jan: 00:00 gmt+0800 (China Standard Time)

2015-01-01t00:00:00z

Thu Jan: 00:00 gmt+0800 (China Standard Time)

2015-01-01t00:00:00+08:00

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

2015135

not hold

20150101

not hold

2015-w011

not hold

-2015-01-01 00:00:00

BC not supported, returned by is a

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

Rule summary:

    • A datetime string with a time zone represents the time of the specified time zone. A datetime string without a time zone, in two cases: the DateTime string for the class ISO structure represents the time of the system's current time zone, whereas the ISO standard structure's datetime string represents the current time of the Greenwich Meridian.
    • Z or Z does not only represent UTC time, but also indicates that the DateTime string represents the time of 0 offset, as in Greenwich Meridian time. However, after Z can continue the overtime, the offset is calculated starting from 0.
    • Because date is generated on the client, the actual date has been converted to the time of the local system, and it is important to note that when the DateTime string becomes a Date object, the time and date values may be offset from the values in the string.

Other supported formats

Example

Results

2015/01/02

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

2015/01/02 00:00:00

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

2015/01/02 00:00

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

2015/1/2

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

01/02/2015

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

1/2/2015

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

1/2 2015

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

01/02 2015

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

1 2 2015

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

IE5-10 does not support this date format

1 2,2015

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

IE5-10 does not support this date format

1,2,2015

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

IE5-10 does not support this date format

2015

Thu Jan 00:00:00 gmt+0800 (China Standard Time)

IE5-10 does not support this date format

May 1,2015

Fri 00:00:00 gmt+0800 (China Standard Time)

May 1 2015

Fri 00:00:00 gmt+0800 (China Standard Time)

may,1,2015

Fri 00:00:00 gmt+0800 (China Standard Time)

may,1 2015

Fri 00:00:00 gmt+0800 (China Standard Time)

Local date representation format

JavaScript Date Full Solution

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.