JavaScript toJSON() Method
Example
Returns a Date object as a string, formatted as JSON data:
var d=new Date();
var n=d.toJSON();
n Output result:
Try it »
Definition and Usage
The toJSON() method converts a Date object to a string and formats it as JSON data.
JSON data uses the same format as the ISO-8601 standard: YYYY-MM-DDTHH:mm:ss.sssZ
Browser support





All major browsers support the toJSON() method
Note: Internet Explorer 8 and earlier IE versions do not support this method.
Syntax
Date
.toJSON()
Return Value
| Type | Description |
|---|---|
| String | Date in JSON data format |
Technical Details
| JavaScript version: | 1.8.5 |
|---|
JavaScript Date object