日期转字符串函数js⽇期转字符串时间类型转换
var draftTimeV = "Fri Mar 10 09:44:48 CST 2017"; <!-- ⽰例 -->
//核⼼代码---state
draftTimeV = draftTimeV + "";
var date = "";
var month = new Array();
month["Jan"] = 1; month["Feb"] = 2; month["Mar"] = 3; month["Apr"] = 4; month["May"] = 5; month["Jan"] = 6;
month["Jul"] = 7; month["Aug"] = 8; month["Sep"] = 9; month["Oct"] = 10; month["Nov"] = 11; month["Dec"] = 12;
str = draftTimeV.split(" ");
date = str[5] + "-";
date = date + month[str[1]] + "-" + str[2];
//------end
alert(date);
效果:
//核⼼代码---state
draftTimeV = draftTimeV + "";
var date = "";
var month = new Array();
month["Jan"] = 1; month["Feb"] = 2; month["Mar"] = 3; month["Apr"] = 4; month["May"] = 5; month["Jan"] = 6;
month["Jul"] = 7; month["Aug"] = 8; month["Sep"] = 9; month["Oct"] = 10; month["Nov"] = 11; month["Dec"] = 12;
str = draftTimeV.split(" ");
date = str[5] + "-";
date = date + month[str[1]] + "-" + str[2]+" "+str[3];
//------end
效果:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论