Created
May 8, 2022 01:20
-
-
Save andatoshiki/433ed3cd050f369d99af8418985c9a2a to your computer and use it in GitHub Desktop.
⏲ Automatically send greetings to visitors based on time zone via javscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<head> | |
<title>Show good morning good night wish as per time Javascript</title> | |
</head> | |
<script type="text/javascript"> | |
document.write("<center>"); | |
var day = new Date(); | |
var hr = day.getHours(); | |
if (hr >= 0 && hr < 12) { | |
document.write("Good Morning!"); | |
} else if (hr == 12) { | |
document.write("Good Noon!"); | |
} else if (hr >= 12 && hr <= 17) { | |
document.write("Good Afternoon!"); | |
} else { | |
document.write("Good Evening!"); | |
} | |
document.write("</center>"); | |
</script> | |
</html> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment