Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save achudars/5520280 to your computer and use it in GitHub Desktop.
Save achudars/5520280 to your computer and use it in GitHub Desktop.
Date display for common use in JavaScript in the format: Sunday, August 18, 2013
var now = new Date();
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
function fourdigits(number) {
return (number < 1000) ? number + 1900 : number;
}
today = days[now.getDay()] + ", " +
months[now.getMonth()] + " " +
date + ", " +
(fourdigits(now.getYear())) ;
document.write(today);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment