I need to format a date as yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
as specified by Parse's REST API for Facebook. I was wondering what the most lightweight solution to this would be.
Date formatting Dates are formatted using the following format: "yyyy-MM-dd'T'hh:mm:ss'Z'" if in UTC or "yyyy-MM-dd'T'hh:mm:ss[+|-]hh:mm" otherwise. On the contrary to the time zone, by default the number of milliseconds is not displayed.
ISO 8601. This format is defined by the sensible practical standard, ISO 8601. The T separates the date portion from the time-of-day portion. The Z on the end means UTC (that is, an offset-from-UTC of zero hours-minutes-seconds).
The hour, using a 12-hour clock from 01 to 12. More information: The "hh" Custom Format Specifier. The hour, using a 24-hour clock from 0 to 23. More information: The "H" Custom Format Specifier.
Call the toISOString()
method:
var dt = new Date("30 July 2010 15:05 UTC"); document.write(dt.toISOString()); // Output: // 2010-07-30T15:05:00.000Z
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With