datejs könnte folgendes analysieren, vielleicht möchten Sie es ausprobieren.
Date.parse('1997-07-16T19:20:15')
Date.parse('1997-07-16T19:20:30+01:00')
Bearbeiten: Regex-Version
x = "2011-01-28T19:30:00EST"
MM = ["January", "February","March","April","May","June","July","August","September","October","November", "December"]
xx = x.replace(
/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):\d{2}(\w{3})/,
function($0,$1,$2,$3,$4,$5,$6){
return MM[$2-1]+" "+$3+", "+$1+" - "+$4%12+":"+$5+(+$4>12?"PM":"AM")+" "+$6
}
)
Ergebnis
January 28, 2011 - 7:30PM EST
Edit2: Ich habe meine Zeitzone auf EST geändert und jetzt folge ich
x = "2011-01-28T19:30:00-05:00"
MM = {Jan:"January", Feb:"February", Mar:"March", Apr:"April", May:"May", Jun:"June", Jul:"July", Aug:"August", Sep:"September", Oct:"October", Nov:"November", Dec:"December"}
xx = String(new Date(x)).replace(
/\w{3} (\w{3}) (\d{2}) (\d{4}) (\d{2}):(\d{2}):[^(]+\(([A-Z]{3})\)/,
function($0,$1,$2,$3,$4,$5,$6){
return MM[$1]+" "+$2+", "+$3+" - "+$4%12+":"+$5+(+$4>12?"PM":"AM")+" "+$6
}
)
Rückkehr
January 28, 2011 - 7:30PM EST
Grundsätzlich
String(new Date(x))
Rückkehr
Fri Jan 28 2011 19:30:00 GMT-0500 (EST)
Regex-Teile konvertieren nur die obige Zeichenfolge in das gewünschte Format.
January 28, 2011 - 7:30PM EST