- 后端传过来的时间格式是英文时间格式
2.更改格式代码,formatdate(time)函数写在methods内
formatdate(time) {
var d = new Date(time);
var curr_date = d.getDate();
var curr_month = d.getMonth() + 1;
var curr_year = d.getFullYear();
var h = d.getHours(); //获取小时
var m = d.getMinutes(); //获取分钟
var s = d.getSeconds(); //获取秒
String(curr_month).length < 2 ? (curr_month = "0" + curr_month) : curr_month;
String(curr_date).length < 2 ? (curr_date = "0" + curr_date) : curr_date;
String(h).length < 2 ? (h = "0" + h) : h;
String(m).length < 2 ? (m = "0" + m) : m;
String(s).length < 2 ? (s = "0" + s) : s;
var timeformat = curr_year + "-" + curr_month + "-" + curr_date + " " + h + ":" + m + ":" + s;
return timeformat;
}
3.修改結果