SO - parsing and formatting dates
http://stackoverflow.com/questions/8368208/how-to-format-date-in-correct-format-in-java-script
by dzejkej
HTML
<script src="http://stevenlevithan.com/assets/misc/date.format.js"></script>
UTC time is: <span id="result"></span>
CSS
#result {
font-weight: bolder;
font-size: 20px;
}
JavaScript
function convertTime(dateString) {
// get ms part from the string
var milis = +dateString.substring(0, 13);
// get timezone part as "# of hours from UTC", e.g. "-0500" -> -5
var offset = +dateString.substring(13, 16);
// move the time for "offset" number of hours
var date = new Date(milis - offset * 3600000);
// using http://stevenlevithan.com/assets/misc/date.format.js
return date.format("UTC:h:MM TT, mmm dS yyyy");
}
document.getElementById("result").innerHTML = convertTime("1322919399447-0500");