Skip to content

Instantly share code, notes, and snippets.

@darlacameron
Created October 1, 2015 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darlacameron/54a48da22f72fde256a4 to your computer and use it in GitHub Desktop.
Save darlacameron/54a48da22f72fde256a4 to your computer and use it in GitHub Desktop.
function parseDate(date) {
var months = ['Jan.', 'Feb.', 'March', 'April', 'May', 'June', 'July', 'Aug.', 'Sept.', 'Oct.', 'Nov.', 'Dec.'];
// get date (no time)
var justDate = date.split('T');
var dateSplit = justDate[0].split('-');
// format date and year
var newDate = new Date(dateSplit[0],dateSplit[1]-1,dateSplit[2]),
day = newDate.getDate(),
year = newDate.getFullYear(),
month = months[newDate.getMonth()],
date = month + ' ' + day + ', ' + year;
// insert into dom
$('#last-updated').text(date);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment