Parsing the date shouldn't be too difficult - all the components are in the right order so you just need to split on the special characters, subtract 1 from the month value and apply the array, minus the last element, to Date.UTC():
function parseDate(dStr) {
var d = dStr.split(/[-:T+]/); d[1] -= 1; d.pop();
var date = new Date(Date.UTC.apply(Date, d));
This gives us a Date object for the date specified, the rest is just formatting each component back into a string:
// Declare an array of short month names
var mon = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov", "Dec"];
// Determine between AM and PM
ampm = date.getHours() > 12 ? "PM" : "AM",
// Prepare for working out the date suffix
nth = date.getDate();
// Date is nth for 11th, 12th and 13th
if (nth >= 11 && nth <= 13)
nth = "th";
// Otherwise it's st, nd, rd, th if the date ends in 1, 2, 3 or anything else
else
nth = ["", "st", "nd", "rd"][(nth+"").slice(-1)] || "th";
// Return the string formatted date
return (date.getHours() % 12) + ":" + (date.getMinutes()) + " " + ampm +
" " + mon[date.getMonth()] + " " + date.getDate() + nth;
}
// Example:
parseDate("2010-10-06T03:39:41+0000");
// -> "4:39 AM Oct 6th" (in my timezone)
If you want the output to be the same regardless of timezone (the original time supplied), you need to swap the methods getHours(), getMinutes(), etc for getUTCHours(), getUTCMinutes(), etc.