Latest web development tutorials

JavaScript toJSON () method

Date Object Reference JavaScript Date Object

Examples

Date object string and formatted as JSON data:

var d=new Date();
var n=d.toJSON();

n output:


try it"

Definition and Usage

toJSON () method can be Date object to a string, and format for the JSON data format.

JSON data in the same format as the standard x ISO-8601: YYYY-MM-DDTHH: mm: ss.sssZ


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support toJSON () method

NOTE: Internet explorer 8 and earlier versions of IE does not support this method.


grammar

Date.toJSON()

return value

Type 描述
String JSON数据格式的日期

technical details

JavaScript version: 1.8.5


Date Object Reference JavaScript Date Object