您的位置:首页 > Web前端 > JavaScript

js日期格式化

2016-01-17 23:12 537 查看
/

/格式化
function timeCon2(obj){
if(obj==""||obj==undefined){
return false;
}else{
var timeHtml = "";
var time = obj;
time = time.split(' ');
var year = time[2]//年
var day = time[1].replace(',','');//日
var wen = time[3];//时分秒
var non = time[4];//上午or下午
var month = ""//月
if(non=="AM"){
non = "上午";
}else if(non=="PM"){
non = "下午"
}
if(time[0]=='Jan'){//一月
month = "1";
}else if(time[0]=='Feb'){//二月
month = "2";
}else if(time[0]=='Mar'){//三月
month = "3";
}else if(time[0]=='Apr'){//四月
month = "4";
}else if(time[0]=='May'){//五月
month = "5";
}else if(time[0]=='Jun'){//六月
month = "6";
}else if(time[0]=='Jul'){//七月
month = "7";
}else if(time[0]=='Aug'){//八月
month = "8";
}else if(time[0]=='Sep'){//九月
month = "9";
}else if(time[0]=='Oct'){//十月
month = "10";
}else if(time[0]=='Nov'){//十一月
month = "11";
}else if(time[0]=='Dec'){//十二月
month = "12";
}

timeHtml+=year+'-'+month+'-'+day+' '+wen;
return timeHtml;
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: