解决使用mybatis查询出来的时间字段为数字的问题,在前端来转化

使用mybatis查询出来的时间字段为一串数字,很奇怪,我明明已经转化了呢,为什么还会这样呢?

那就解决吧,使用JS来解决,挺方便的。

以下的代码直接复制黏贴就可以了。

function timestampToTime(timestamp) {
	   var date = new Date(timestamp);//时间戳为10位需*1000,时间戳为13位的话不需乘1000
	   Y = date.getFullYear() + '-';
	   M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
	   D = date.getDate() + ' ';
	   h = date.getHours() + ':';
	   m = date.getMinutes() + ':';
	   s = date.getSeconds();
	   return Y+M+D;
}

像我这样使用,就可以了

发布了173 篇原创文章 · 获赞 92 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_42995083/article/details/105520656
今日推荐