If the current time (HOUR) is less than 20:00, output "Good day" - Javascript Date

Javascript examples for Date:getUTCSeconds

Description

If the current time (HOUR) is less than 20:00, output "Good day"

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials