Created
September 2, 2011 02:38
-
-
Save akb/1187817 to your computer and use it in GitHub Desktop.
pretty print a date in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
+1