I have a date with the format Sun May 11,2014
.
(我有一个日期为Sun May 11,2014
。)
How can I convert it to 2014-05-11
using JavaScript? (如何使用JavaScript将其转换为2014-05-11
?)
function taskDate(dateMilli) {
var d = (new Date(dateMilli) + '').split(' ');
d[2] = d[2] + ',';
return [d[0], d[1], d[2], d[3]].join(' ');
}
var datemilli = Date.parse('Sun May 11,2014');
taskdate(datemilli);
The code above gives me the same date format, sun may 11,2014
.
(上面的代码为我提供了相同的日期格式,即sun may 11,2014
。)
How can I fix this? (我怎样才能解决这个问题?)
ask by user3625547 translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…