41 lines
1 KiB
HTML
41 lines
1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>beer</title>
|
|
</head>
|
|
<body>
|
|
<!-- Display the countdown timer in an element -->
|
|
<p id="demo"></p>
|
|
|
|
<script>
|
|
// Update the count down every 1 second
|
|
|
|
var x = setInterval(function() {
|
|
|
|
// Get today's date and time
|
|
// var now = new Date().getTime();
|
|
var now = new Date().getTime();
|
|
var today = new Date();
|
|
today.setHours(17, 00);
|
|
var goal = today.getTime();
|
|
|
|
// Find the distance between now and the count down date
|
|
var distance = goal - now;
|
|
|
|
// Time calculations for days, hours, minutes and seconds
|
|
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
|
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
|
|
|
// Display the result in the element with id="demo"
|
|
document.getElementById("demo").innerHTML = hours + "h "
|
|
+ minutes + "m ";
|
|
|
|
// If the count down is finished, write some text
|
|
if (distance < 0) {
|
|
clearInterval(x);
|
|
document.getElementById("demo").innerHTML = "BEER TIME !";
|
|
}
|
|
}, 1000);
|
|
</script>
|
|
</body>
|
|
</html>
|