Javascript examples for Date:getUTCSeconds
If the current time (HOUR) is less than 20:00, output "Good day"
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/* w ww . j av a 2s .c o m*/ var time = new Date().getHours(); if (time < 20) { document.getElementById("demo").innerHTML = "Good day"; } } </script> </body> </html>