Reputation: 894
While executing new Date().toLocaleString()
on chrome returns
"5/2/2019, 11:55:00 AM",
executing the same code on nodejs returns
"5/2/2019, 11:55:00", without AM/PM
I need to have a 12-hours format date with AM/PM mentioned in nodejs similar to what is returned in browser.
Am i missing something and this is the expected behavior?
Upvotes: 2
Views: 1214
Reputation: 10591
it's implementation dependent, i.e. different implementation can return different string format.
20.3.4.41 Date.prototype.toString()
The following steps are performed:
... Else, Let tv be this time value. Return ToDateString(tv).
20.3.4.41.1 Runtime Semantics: ToDateString(tv)
The following steps are performed:
Assert: Type(tv) is Number.
If tv is NaN, return "Invalid Date".
Return an implementation-dependent String value that represents tv as a date and time in the current time zone using a convenient, human-readable form.
It seems like there would be a standard format in the future, though.
Upvotes: 2