Skip to content

Instantly share code, notes, and snippets.

@jeremyblaze
Last active August 29, 2015 14:24
Show Gist options
  • Save jeremyblaze/e123006e792c50dcc3f3 to your computer and use it in GitHub Desktop.
Save jeremyblaze/e123006e792c50dcc3f3 to your computer and use it in GitHub Desktop.
Greet website visitors with a happy message!
<div id="greeting"></div>
<script type="text/javascript" src="greetings.js">
now = new Date();
hrs = now.getHours();
msg = "";
if (hrs > 0) msg = "Morning, earlybird.";
if (hrs > 6) msg = "Morning.";
if (hrs > 12) msg = "Afternoon.";
if (hrs > 17) msg = "Evening.";
if (hrs > 22) msg = "Greetings.";
document.getElementById("greeting").innerHTML = msg;
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment