Skip to content

Instantly share code, notes, and snippets.

@andatoshiki
Created May 8, 2022 01:20
Show Gist options
  • Save andatoshiki/433ed3cd050f369d99af8418985c9a2a to your computer and use it in GitHub Desktop.
Save andatoshiki/433ed3cd050f369d99af8418985c9a2a to your computer and use it in GitHub Desktop.
⏲ Automatically send greetings to visitors based on time zone via javscript
<!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