Javascript format date -
this question has answer here:
i having hardest time trying format ie 8+, code works in google chrome, dies in ie. can shed little light.
2013-04-08t10:33:05.427 <-- format month day year time am/pm
when know time format can make pretty garenteed regexp:
/(\d{4})-(\d{2})-(\d{2})t(\d{2}):(\d{2}):(\d{2})(.+)/ code:
var str = "2013-04-08t10:33:05.427"; str = str.replace(/(\d{4})-(\d{2})-(\d{2})t(\d{2}):(\d{2}):(\d{2})(.+)/, function(_, y, m, d, h, mi, s) { var ampm; if ( h < 12 ) { ampm = 'am'; } else { ampm = 'pm'; h-=12; } return [m, ' ', d, ' ', y, ' ', h, ':', mi, ':', s, ' ', ampm].join(''); }); str; // "04 08 2013 10:33:05 am"
Comments
Post a Comment