Created
April 28, 2015 15:14
-
-
Save josephmosby/5173c4d0d0804375f290 to your computer and use it in GitHub Desktop.
JS Format an ISO8601 date as Django date string representation
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
var format_date = function(date) { | |
var month_names = ["January", "February", "March", "April", "May", "June", | |
"July", "August", "September", "October", "November", "December"]; | |
js_date = new Date(date); | |
formatted_date = month_names[js_date.getMonth()] + ' ' + js_date.getDate() + ', ' + js_date.getFullYear() | |
+ ', ' + js_date.getUTCHours() + ':' + js_date.getUTCMinutes(); | |
if(js_date.getHours() < 12) { | |
formatted_date += " a.m."; | |
} else { | |
formatted_date += " p.m."; | |
} | |
return formatted_date; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment