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