NokX
1
i’m taking an existing date (twitter feed) and i want to change the formatting. it’s been a while since i’ve messed with dates in javascript.
what i have: Fri, 26 Feb 2010 18:33:40 +0000
what i want: 1:33pm Feb 26th
i’m Eastern Time (-5).
what can i do with javascript to get this date?
mrhoo
2
//
Date.fromTwit=function(s){
var d, tz= s.match(/[\\-\\+]\\d{4}$/),
day= s.split(/\\W+/),
d= new Date(day.slice(1, 4).join(' '));
d.setUTCHours(day[4], day[5], day[6]);
tz= tz? Number(tz): 0;
d.setUTCMinutes(d.getUTCMinutes()+tz);
return d;
}
calling Date.fromTwit(s1) returns a date object.
[B]var s1= ‘Fri, 26 Feb 2010 18:33:40 +0000’;
alert(Date.fromTwit(s1).toLocaleString())[/B]>>Friday, February 26, 2010 1:33:40 PM
use the date methods to format it differently.