InterviewSolution
Saved Bookmarks
| 1. |
Get today’s date in JavaScript |
|
Answer» To convert a date object to string in JavaScript, use the toLocaleString() method. 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: <!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 |
|