Skip to content

Instantly share code, notes, and snippets.

@callumlocke
Created September 11, 2015 12:39
Show Gist options
  • Save callumlocke/4453aa024c77f809f713 to your computer and use it in GitHub Desktop.
Save callumlocke/4453aa024c77f809f713 to your computer and use it in GitHub Desktop.
Format a date object in this style: "July 21, 2014"
var monthNames = [
'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'
];
function formatDate(date) {
return (
monthNames[date.getUTCMonth()] + ' ' +
date.getUTCDate() + ', ' +
date.getUTCFullYear()
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment