Convert to JSON
suggest changeconst date1 = new Date();
date1.toJSON();
For a valid date, toJSON() returns the same string as toISOString(). The value below is an example of that format, not the result of new Date() at an arbitrary time.
Example: ā2016-04-14T23:49:08.596Zā
toJSON() throws RangeError on an invalid date.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents