Refresh

This website www.w3schools.blog/tojson-javascript-js is currently offline. Cloudflare's Always Online™ shows a snapshot of this web page from the Internet Archive's Wayback Machine. To check for the live version, click Refresh.

JavaScript toJSON()

The JavaScript date toJSON() method is used to get a string representing the Date object and serializing the Date object at the time of JSON serialization.

Syntax:

dateObj.toJSON();

Return:
String representation of the date portion of a Date object.

Example:

<!DOCTYPE html>
<html>
<body>
<script>
var bday=new Date("November 16, 1994 21:10:10");
document.writeln(bday.toJSON());
</script>
</body>
</html>