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>