Skip to content

Instantly share code, notes, and snippets.

@kranthilakum
Last active December 14, 2015 04:49
Show Gist options
  • Save kranthilakum/5031127 to your computer and use it in GitHub Desktop.
Save kranthilakum/5031127 to your computer and use it in GitHub Desktop.
Display current day of the week using JavaScript getDay()
<!DOCTYPE html>
<html>
<head>
<script>
function today()
{
var day = new Date();
var dayNames = new Array ("Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday");
var x = document.getElementById("myDay");
x.innerHTML = "Happy " + dayNames[day.getDay()] + "!";
}
</script>
</head>
<body onload="today()">
<p id="myDay"></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment