Skip to content

Instantly share code, notes, and snippets.

@tkalfigo
Created January 1, 2014 00:36
Show Gist options
  • Save tkalfigo/8203694 to your computer and use it in GitHub Desktop.
Save tkalfigo/8203694 to your computer and use it in GitHub Desktop.
Date.prototype.prettyPrint = function () {
return ['Jan.', 'Feb.', 'Mar.',
'Apr.', 'May', 'Jun.',
'Jul.', 'Aug.', 'Sep.',
'Oct.', 'Nov.', 'Dec.'][this.getMonth()] + " " +
(function (d) {
var s = d.toString(), l = s[s.length-1];
return s+(['st','nd','rd'][l-1] || 'th');
})(this.getDate()) + ", " +
this.getFullYear() + " " +
this.getHours() + ":" + ("0" + this.getMinutes()).slice(-2);
}
Usage: (new Date()).prettyPrint();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment