Skip to content

Instantly share code, notes, and snippets.

@akb
Created September 2, 2011 02:38
Show Gist options
  • Save akb/1187817 to your computer and use it in GitHub Desktop.
Save akb/1187817 to your computer and use it in GitHub Desktop.
pretty print a date in javascript
(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);
}).call(new Date())
@aalemayhu
Copy link

+1

@Gerst20051
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment