The toJSON()
method returns a Json string representation of the Date object.
dateObj.toJSON()
toJSON()
returns a string via toISOString()
representing the Date object's value.
This method is for JSON serialization.
var jsonDate = (new Date()).toJSON(); console.log(jsonDate);//from w ww .j a va 2s . co m var backToDate = new Date(jsonDate); console.log(backToDate);