English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript toJSON() Method

 JavaScript Date Object

toJSON()The method returns the string representation of a date object in JSON date format.

JSON dates have the same format as ISO-8601Format with the same standard: YYYY-MM-DDTHH:mm:ss.sssZ

Syntax:

date.toJSON()
var d = new Date();
var str = d.toJSON();
document.getElementById('result').innerHTML = str;
Test See‹/›

Browser Compatibility

The numbers in the table specify the first browser version that fully supports the toJSON() method:

Method
toJSON()43.5YesYes9

Technical Details

Return Value:A string representing a date and time in JSON date format
JavaScript Version:ECMAScript 5

 JavaScript Date Object