JavaScript Date toJSON() Method
- Previous Page toISOString()
- Next Page toLocaleDateString()
- Go to the Previous Level JavaScript Date Reference Manual
Definition and Usage
toJSON()
The method converts a Date object to a string in the format of JSON date.
The format of JSON date is the same as the ISO-8601 standard: YYYY-MM-DDTHH:mm:ss.sssZ
Example
Returns a Date object as a string in the format of JSON date:
var d = new Date(); var n = d.toJSON();
Syntax
Date.toJSON()
Parameters
No parameters.
Technical Details
Return Value: | A string representing the date and time formatted as a JSON date. |
---|---|
JavaScript Version: | ECMAScript 5 |
Browser Support
The numbers in the table indicate the first browser version that fully supports this method.
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
toJSON() | Support | 9 | Support | Support | Support |
- Previous Page toISOString()
- Next Page toLocaleDateString()
- Go to the Previous Level JavaScript Date Reference Manual