标签:
传入:Json格式的时间
JS如下:
yyyy-M(MM)-d(dd) H(HH):m(mm):s(ss)
function timeStamp2String(time) { var data=time; var datetime=new Date(parseInt(data.replace("/Date(","").replace(")/",""),10)); var year=datetime.getFullYear(); var month=datetime.getMonth()+1; var date=datetime.getDate(); var hour=datetime.getHours(); var minute=datetime.getMinutes(); var second=datetime.getSecords(); return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second; }
yyyy-MM-dd HH:mm:ss
function timeStamp2String(time) { var data=time; var datetime=new Date(parseInt(data.replace("/Date(","").replace(")/",""),10)); var year=datetime.getFullYear(); var month=datetime.getMonth()+1<10?"0"+(datetime.getMonth()+1):datetime.getMonth()+1; var date=datetime.getDate()<10?"0"+datetime.getDate():datetime.getDate(); var hour=datetime.getHours()<10:"0"+datetime.getHours():datetime.getHours(); var minute=datetime.getMinutes()<10?datetime.getMinutes():datetime.getMinutes(); var second=datetime.getSecords()<10?datetime.getSecords():datetime.getSecords(); return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second; }
运用时,在js中调用
标签:
原文地址:http://www.cnblogs.com/xibianriluo/p/5001582.html