//时间数据类型处理
function getTime(gmt_create.time){
var datetime = new Date();
datetime.setTime(time);
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 ? "0" + datetime.getMinutes() : datetime.getMinutes();
var second = datetime.getSeconds()< 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
return year + "/" + month + "/" + date+" "+hour+":"+minute+":"+second;
}
json分装后的格式:
gmt_create":{"date":9,"hours":17,"seconds":42,"month":7,"nanos":0,"timezoneOffset":-480,"year":120,"minutes":51,"time":1596966702000,"day":0}
注:参数是createTime中的time属性的值
亲测时的案例:
数据库时间数据类型:timestamp/datetime
实体类参数数据类型:date
未处理时的效果:
????????[object object]?
参数错误时的效果:
????????eg:直接gmt_create:?
???????????????? NaN-NaN-NaN NaN:NaN:NaN
|