Mysql Datetime 字段数据类型,web展示时间格式转换:
Date类型的数据:/Date(1553668826000)/ 转换为:2019-03-27 14:40:26
JavaScripts方法:
/**
* DateTime 转换
* 时间日期格式化的函数
* @param {any} date
* "yyyy-mm-dd HH-mm-ss"
*/
function dateFormat(date) {
if (date == null) return date;
var d = eval('new ' + date.substr(1, date.length - 2));
var retMsg = "";
retMsg += d.getFullYear() + "-";
retMsg += checkTime(d.getMonth() + 1) + "-";
retMsg += checkTime(d.getDate()) + " ";
retMsg += checkTime(d.getHours()) + ":";
retMsg += checkTime(d.getMinutes()) + ":";
retMsg += checkTime(d.getSeconds());
return retMsg;
}