export default {
//补0
add0(m) {
return m < 10 ? '0' + m : m
},
//时间戳转时间
format: function(shijianchuo, type) {
if (!shijianchuo) return;
if (parseInt(shijianchuo) < 10000000000) {
shijianchuo = parseInt(shijianchuo) * 1000
}
var time = new Date(shijianchuo);
var y = time.getFullYear();
var m = time.getMonth() + 1;
var d = time.getDate();
var h = time.getHours();
var mm = time.getMinutes();
var s = time.getSeconds();
var time = {
y,
m: this.add0(m),
d: this.add0(d),
h: this.add0(h),
mm: this.add0(mm),
s: this.add0(s)
}
var timeValue = time;
if(type == 1) {
timeValue = time.y + '.' + time.m + '.' + time.d + ' ' + time.h + ':' + time.mm + ':' + time.s;
}else {
timeValue = time;
}
return timeValue
},
// 时间戳转时间格式(中国标准时间)
getTi
js 时间格式处理
最新推荐文章于 2024-07-17 15:26:15 发布