如何把 Wed, 25 Apr 2007 13:40:43 GMT 日期转换为 2007-4-25 13:40:43
------解决方案--------------------
<script>
function zero(num, s) {
var tmp = " " + num;
for (;tmp.length <s; tmp = "0 " + tmp);
return tmp;
}
function formatDate(d, fmt) {
var yyyy = d.getUTCFullYear();
var mm = zero(d.getUTCMonth() + 1, 2);
var dd = zero(d.getUTCDate(), 2);
var hh = zero(d.getUTCHours(), 2);
var mi = zero(d.getUTCMinutes(), 2);
var ss = zero(d.getUTCSeconds(), 2);
return fmt.replace(/yyyy/ig, yyyy).replace(/mm/ig, mm).replace(/dd/ig, dd).replace(/hh/ig, hh).replace(/mi/ig, mi).replace(/ss/ig, ss);
}
var d = new Date( "Wed, 25 Apr 2007 13:40:43 GMT ");
alert(formatDate(d, "yyyy-mm-dd hh:mi:ss "));
</script>