function dateTO(data) {
//data为时间戳
var date = new Date(data * 1000);
var Y = date.getFullYear();
var M = (date.getMonth() + 1 < 10 ? ‘0’ + (date.getMonth() + 1) : date.getMonth() + 1);
var D = (date.getDate() < 10 ? ‘0’ + date.getDate() : date.getDate()) + ’ ';
var h = (date.getHours() < 10 ? ‘0’ + date.getHours() : date.getHours()) + ‘:’;
var m = (date.getMinutes() < 10 ? ‘0’ + date.getMinutes() : date.getMinutes()) + ‘:’;
var s = (date.getSeconds() < 10 ? ‘0’ + date.getSeconds() : date.getSeconds());
var strDate = Y + ‘年’ + M + ‘月’; //转换为年月日时分秒
return strDate;
}
//把时间戳转换为时间
最新推荐文章于 2021-11-16 19:31:35 发布