1.

Get today’s date in JavaScript

Answer»

To convert a date object to string in JavaScript, use the toLocaleString() method.

The following is the syntax:

Date.toLocaleString();

Create a Date object: 

var date = new Date();

Now convert the above date object to string:

date.toLocaleString();

The example demonstrates how to convert Date object to string:

&LT;!DOCTYPE html> <html> <body> <script> var date = new Date(); var RES = date.toLocaleString(); document.write(res); </script> </body> </html>

The output:

12/14/2018, 8:25:52 PM


Discussion

No Comment Found