Skip to content

Instantly share code, notes, and snippets.

@luciovilla
Created July 16, 2018 17:56
Show Gist options
  • Save luciovilla/698f9711186cf6ff2e44ed7e5debb98b to your computer and use it in GitHub Desktop.
Save luciovilla/698f9711186cf6ff2e44ed7e5debb98b to your computer and use it in GitHub Desktop.
Convert current date to AP style
function dateConverter(timeStamp){
var UNIX_timestamp = new Date(timeStamp.replace(/\s/, 'T')).getTime();
var a = new Date(UNIX_timestamp);
var months = ['Jan.','Feb.','March','April','May','June','July','Aug.','Sept.','Oct.','Nov.','Dec.'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var day = a.getDate();
var time = month + ' ' + day + ', ' + year ;
return time;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment