Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Get Hours, Minutes, and Seconds from a Date Object</title> </head> <body> <script> let d = new Date(); // Extracting time part document.write(d.getHours() + "<br>"); // Display the number of hours into the day (0-23) document.write(d.getMinutes() + "<br>"); // Display the number of minutes into the hour (0-59) document.write(d.getSeconds() + "<br>"); // Display the seconds into the minute (0-59) document.write(d.getMilliseconds() + "<br>"); // Display the number of milliseconds into second (0-999) document.write(d.getTime() + "<br>"); // Display the number of milliseconds since 1/1/1970 document.write(d.getTimezoneOffset()); // Display the time-zone offset (from Greenwich Mean Time) in minutes </script> </body> </html>