-
-
Save matthewlind/f511aaab8543f60d2b2441fe4f2f1389 to your computer and use it in GitHub Desktop.
show todays date
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
// get todays date | |
// Get today's current date. | |
var now = new Date(); | |
// Array list of days. | |
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); | |
// Array list of months. | |
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December'); | |
// Calculate the number of the current day in the week. | |
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate(); | |
// Calculate four digit year. | |
function fourdigits(number) { | |
return (number < 1000) ? number + 1900 : number; | |
} | |
// Join it all together | |
today = days[now.getDay()] + " " + | |
months[now.getMonth()] + " " + | |
date + ", " + | |
(fourdigits(now.getYear())); | |
// Print out the data. | |
document.write("" +today+ " "); | |
// End --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment