我想从此格式"yyyy-MM-dd'T'HH:mm:ss.SSS"
转换日期
使用JavaScript到Mon, May 09 2016 08:12:29
,下面的代码不起作用。请咨询
var str2 = "2016-05-09T08:12:29.110";
var date2 = Date.parse( str2 );
alert( date2.toString( 'EEE, MMM d yyyy HH:mm:ss' ) );`
答案 0 :(得分:0)
试试这个
var str2 = "2016-05-09T08:12:29.110";
var date2 =new Date(str2);
alert( date2 );
答案 1 :(得分:0)
试试这个:
var str2 = "2016-05-09T08:12:29.110";
var date2 = new Date(Date.parse(str2));
var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
function pad(n, number) {
var str = number.toString();
var result = '';
for (var i=0; i<n-str.length; ++i) {
result += '0';
}
return result + str;
}
document.body.innerHTML = days[date2.getDay()] + ', ' + months[date2.getMonth()] + ' ' + pad(2, date2.getDate()) + ' ' + date2.getFullYear() + ' ' + pad(2, date2.getUTCHours()) + ':' + pad(2, date2.getMinutes()) + ':' + pad(2, date2.getSeconds());
&#13;