js中怎么将一个2004 May 26这种类型的字符串转换成2004-5-26时间格式
1个回答
展开全部
function transDateFormat(d) {
var d_elements = new Array();
var monthE2N = {Jan:1,Feb:2,Mar:3,Apr:4,May:5,Jun:6,Jul:7,Aug:8,Sep:9,Oct:10,Nov:11,Dec:12};
d_elements = d.split(" ");
return d_elements[0]+"-"+monthE2N[d_elements[1]]+"-"+d_elements[2];
}
alert(transDateFormat("2004 May 26"));
var d_elements = new Array();
var monthE2N = {Jan:1,Feb:2,Mar:3,Apr:4,May:5,Jun:6,Jul:7,Aug:8,Sep:9,Oct:10,Nov:11,Dec:12};
d_elements = d.split(" ");
return d_elements[0]+"-"+monthE2N[d_elements[1]]+"-"+d_elements[2];
}
alert(transDateFormat("2004 May 26"));
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询