jquery-dateFormat
jquery-dateFormat copied to clipboard
Millisecond formatter do not work properly
If I use a formatter like this "yyyy-MM-dd HH:mm:ss.SSS" the milliseconds section (SSS) is not properly formatted. Example:
var outputDatestring = "2015-03-25T13:43:00.123+0000";
var date = new Date(outputDatestring);
console.log($.format.date(date, "yyyy-MM-dd HH:mm:ss.SSS"));
This code logs the following result (my browser is in GTM+01:00, so the hour is correct, but not the milliseconds section): 2015-03-25 14:43:00. Eu
Expected result: 2015-03-25 14:43:00.123
Hi @GianlucaVagnoni
Unfortunately, your input format does not seem to be in the expected input list.
From where is that format coming from?
Hi, That format is called ISO 8601, which is one of the most common formats used for serialization/deserialization of Date objects as a string in JSON format.
There is also another common ISO 8601 format:
"2015-03-25T13:43:00.123Z"
...which is what javascript outputs with toISOString()
new Date().toISOString()
"2020-03-25T19:21:42.398Z"
Regards.