//转换Json "/Date(1602691200000)/"类型 Date时间戳
function DateFormat(jsondate) {
jsondate = jsondate.replace("/Date(", "").replace(")/", "");
if (jsondate.indexOf("+") > 0) {
jsondate = jsondate.substring(0, jsondate.indexOf("+"));
}
else if (jsondate.indexOf("-") > 0) {
jsondate = jsondate.substring(0, jsondate.indexOf("-"));
}
var date = new Date(parseInt(jsondate, 10));
var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
return date.getFullYear()
+ "年"
+ month
+ "月"
+ currentDate
+ "日";
+ " "
//不需要日期后边的时间可删除
+ date.getHours()
+ ":"
+ date.getMinutes();
}
JS转换Json的Date时间戳
最新推荐文章于 2023-04-25 08:31:56 发布