1、将 "\/Date(1313572554031)\/" 转化为 “yyyy-MM-dd hh:mm:ss”字符串格式:
//测试 var str = "\/Date(1313572554031)\/"; alert(ParseDateStr(str)); //方法 function ParseDateStr(str) { if (str && str.length==0) { return ""; } try { //把/删除,并转换为正确的javascript时间 var time = eval(‘new ‘ + (str.replace(/\//g, ‘‘))); //格式化成字符串 var timeStr = time.getFullYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds(); return timeStr; } catch (e) { return ""; } }
时间: 2024-11-05 16:39:44