Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Generate Time Strings</title> </head> <body> <script> var d = new Date(); document.write(d.toTimeString() + "<br>"); // Display the time portion of the date document.write(d.toLocaleTimeString()); // Display a localized time string </script> </body> </html>