//秒数转化成小时、分钟、秒数
GetMHS(seconds) {
let h = 0
let m = 0
let s = 0
h = seconds / 3600;
if (h.toString().indexOf(".") != -1) {
h = parseInt(h);
}
var mt = seconds % 3600; //分钟
m = mt / 60;
if (m.toString().indexOf(".") != -1)
m = parseInt(m);
s = mt % 60;
let restime = this.FormatTime(h) + ":" + this.FormatTime(m) + ":" + this.FormatTime(s);
this.setData({
restime
})
},
FormatTime(t) {
if (t < 10)
return "0" + t;
return t;
},
//世界时间转为北京时间
utc2beijing(utc_datetime) {
// 转为正常的时间格式 年-月-日 时:分:秒
var date = new Date(+new Date(utc_datetime) + 8 * 3600 * 1000)
.toISOString()
.replace(/T/g, ' ')
.replace(/\.[\d]{3}Z/, '')
return date // 2017-03-31 16:02:06
},
//
utcTobeijing(utc_datetime){
let updatetime = new Date(utc_datetime).toISOString().replace(/T/g, " ").replace(/\.[\d]{3}Z/, "")
// 处理成为时间戳
let timestamp = new Date(Date.parse(updatetime));
timestamp = timestamp.getTime();
timestamp = timestamp/1000;
// 增加8个小时,北京时间比utc时间多八个时区
item.updatedAt = timestamp+8*60*60;
// 时间戳转为时间
let beijing_datetime = new Date(parseInt(timestamp) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
return beijing_datetime;
}