Date.toJSON

toJSON – Converts a Date object to a string.

Description

Date.toJSON()

JSON does not have a understanding of a date representation. The format of toJSON is compact, human readable, and is understood by most programming languages.

Return values

string primitive.

Examples

Example #1 – toJSON example
var date = new Date(); console.log(date.toJSON()); // Returns a string representation of the given date and time.

External references