Yes, it is ISO 8601. 2006-09-01T07:00:00.000+0000
is the first day of the ninth month of the year 2006, 7 hours, 0 minutes, 0.000 seconds offset 0 hours from UTC. Whether or not decimals are allowed is up to the parties exchanging dates (which is a fancy way of ISO saying "it's optional").
4.2.2.4 Representations with decimal fraction
If necessary for a particular application a decimal fraction of hour, minute or second may be included. If a decimal fraction is included, lower order time elements (if any) shall be omitted and the decimal fraction shall be divided from the integer part by the decimal sign specified in ISO 31-0, i.e. the comma [,] or full stop [.]. Of these, the comma is the preferred sign. If the magnitude of the number is less than unity, the decimal sign shall be preceded by two zeros in accordance with 3.6.
The interchange parties, dependent upon the application, shall agree the number of digits in the decimal fraction. The format shall be [hhmmss,ss], [hhmm,mm] or [hh,hh] as appropriate (hour minute second, hour minute, and hour, respectively), with as many digits as necessary following the decimal sign. A decimal fraction shall have at least one digit. In the examples below it has been agreed to give the smallest time element a decimal fraction with one digit.
(As pointed out by @chansen, technically it should be 2006-09-01T07:00:00.000+00:00
with a separator on the time zone because according to 4.3.3(d) every part must use either the basic format (no separators) or the extended format (with separators), but nobody bothers with that, strptime can't produce that format, and you'll probably break some ISO 8601 parsers).
Outputting this is covered in other answers for both Javascript and moment.js.
Javascript has Date.toISOString for output. Date.new will also accept an ISO 8601 string. Every recent browser should support it, though Internet Explorer only added it in version 9 (IE 8 still represents 5% of desktop users).
Here's the moment.js docs on String formatting. YYYY-MM-DDTHH:MM:SS.MMMZ
is incorrect because you're using M
to mean three different things. What you want is YYYY-MM-DDTHH:mm:ss.SSSZZ
.
- YYYY - year
- MM - month number (2 digit)
- DD - day of month (2 digit)
- HH - hours (2 digit, 24 hour format)
- mm - minutes (2 digit)
- ss - seconds (2 digit)
- SSS - thousands of seconds
- ZZ - UTC offset
M
is for months and lowercasem
is for minutes. You should check the required case for other parts of it too. – Abase