Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@aalemayhu aalemayhu commented Jan 2, 2015

+1

@Gerst20051

This comment has been minimized.

Copy link

@Gerst20051 Gerst20051 commented Jun 1, 2015

👍

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