JavaScript Date toJSON()
Example
Get a date as a string, formatted as a JSON date:
const d = new Date();
let text = d.toJSON();
Try it Yourself »
Description
The toJSON() method returns a date object as a string, formatted as a JSON date.
JSON dates have the same format as the ISO-8601 standard: YYYY-MM-DDTHH:mm:ss.sssZ
Browser Support
toJSON()
is an ECMAScript5 (ES5) feature.
ES5 (JavaScript 2009) fully supported in all modern browsers since July 2013:
Chrome 23 |
IE/Edge 10 |
Firefox 21 |
Safari 6 |
Opera 15 |
Sep 2012 | Sep 2012 | Apr 2013 | Jul 2012 | Jul 2013 |
Syntax
Date.toJSON()
Parameters
None |
Technical Details
Return Value: | A String, representing the date and time formated as a JSON date |
---|---|
JavaScript Version: | ECMAScript 5 |
Related Pages:
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.