Full JavaScript Date solution, JavaScriptDate

Source: Internet
Author: User

Full JavaScript Date solution, JavaScriptDate

Date constructor New Date () | Date ()

If no parameter is specified, the default time is the current time zone of the system. The result is as follows:

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

Generation represents the time of the current system, which can be generated without the use of new. Date itself is a method.

New Date (milliseconds)

This millisecond parameter is the time that has elapsed since 00:00:00.

New Date (datestring)

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

ISO format time

The most significant feature of ISO format time is the separation of hyphens (-) between years, months, and days. The date and time may have a letter (T), followed by a letter Z or time difference.

T is meaningless. It only indicates that the date and time are separated here; Z indicates that the time is UTC time.

ISO format

Result

2015-1

Thu Jan 01 2015 00:00:00 GMT + 0800 (China Standard Time)

2015-1-1

Thu Jan 01 2015 00:00:00 GMT + 0800 (China Standard Time)

2015-1 00:00:00 +

Thu Jan 01 201504: 00: 00 GMT + 0800 (China Standard Time)

00:00:00 +

Thu Jan 01 201504: 00: 00 GMT + 0800 (China Standard Time)

2015-1-1 00: 00: 00Z + 08:00

Thu Jan 01 2015 00:00:00 GMT + 0800 (China Standard Time)

Thu Jan 01 2015 00:00:00 GMT + 0800 (China Standard Time)

00:00:00

Thu Jan 01 2015 00:00:00 GMT + 0800 (China Standard Time)

00:00:00 +

Thu Jan 01 2015 00:00:00 GMT + 0800 (China Standard Time)

2015-01-01 00: 00: 00Z

Thu Jan 01 201508: 00: 00 GMT + 0800 (China Standard Time)

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

Thu Jan 01 2015 00:00:00 GMT + 0800 (China Standard Time)

ISO Standard Format

Result

2015-01

Thu Jan 01 201508: 00: 00 GMT + 0800 (China Standard Time)

2015-01-01

Thu Jan 01 201508: 00: 00 GMT + 0800 (China Standard Time)

2015-01-01T00: 00: 00

Thu Jan 01 201508: 00: 00 GMT + 0800 (China Standard Time)

2015-01-01T00: 00: 00Z

Thu Jan 01 201508: 00: 00 GMT + 0800 (China Standard Time)

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

Thu Jan 01 2015 00:00:00 GMT + 0800 (China Standard Time)

2015135

Not Supported

20150101

Not Supported

2015-W011

Not Supported

-00:00:00

BC is not supported.

Thu Jan 01 2015 00:00:00 GMT + 0800 (China Standard Time)

Rule Summary:

  • The date and time string with the time zone indicates the time of the specified time zone. The date and time string without the time zone is divided into two situations: the date and time string of the ISO-like structure represents the current time zone of the system, the date and time string of the ISO standard structure represents the current time of the Greenwich Meridian.
  • Z or z not only indicates UTC time, Z also indicates that this date and time string represents the time of 0 time difference offset, as in Greenwich Mean. However, the time difference can be added after Z, and the offset is calculated from 0.
  • Because Date is generated on the client, the actual Date has been converted to the time of the local system. Note that after the Date and time string is changed to the Date object, the value of time and date may be different from the value in the string.

Other supported formats

Example

Result

2015

Thu Jan 02 2015 00:00:00 GMT + 0800 (China Standard Time)

00:00:00

Thu Jan 02 2015 00:00:00 GMT + 0800 (China Standard Time)

Thu Jan 02 2015 00:00:00 GMT + 0800 (China Standard Time)

Thu Jan 02 2015 00:00:00 GMT + 0800 (China Standard Time)

01/02/2015

Thu Jan 02 2015 00:00:00 GMT + 0800 (China Standard Time)

1/2/2015

Thu Jan 02 2015 00:00:00 GMT + 0800 (China Standard Time)

1/2 2015

Thu Jan 02 2015 00:00:00 GMT + 0800 (China Standard Time)

01/02 2015

Thu Jan 02 2015 00:00:00 GMT + 0800 (China Standard Time)

1 2 2015

Thu Jan 02 2015 00:00:00 GMT + 0800 (China Standard Time)

The IE5-10 does not support this date format

1 2,2015

Thu Jan 02 2015 00:00:00 GMT + 0800 (China Standard Time)

The IE5-10 does not support this date format

2015

Thu Jan 02 2015 00:00:00 GMT + 0800 (China Standard Time)

The IE5-10 does not support this date format

2015

Thu Jan 02 2015 00:00:00 GMT + 0800 (China Standard Time)

The IE5-10 does not support this date format

May 1,2015

Fri May 01 2015 00:00:00 GMT + 0800 (China Standard Time)

May 1 2015

Fri May 01 2015 00:00:00 GMT + 0800 (China Standard Time)

May, 1,2015

Fri May 01 2015 00:00:00 GMT + 0800 (China Standard Time)

May, 1 2015

Fri May 01 2015 00:00:00 GMT + 0800 (China Standard Time)

Date Format

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.