CodesJava

Easy learning with example program codes

JavaScript toJSON() method

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 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>

Output:

1994-11-16T15:40:10.000Z
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status