年月日时分秒处理时间差—标准的时间格式处理时间差
例如: 2020-10-16 15:55:03
var start_time
= "2020-10-20T15:05:54Z";
function rTime(date
) {
var json_date
= new Date(date
).toJSON();
return new Date(new Date(json_date
) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
}
let startTime
= rTime(start_time
);
function calculationTime(startTime_a
) {
var s1
= new Date(startTime_a
.replace(/-/g, "/")),
s2
= new Date(),
runTime
= parseInt((s2
.getTime() - s1
.getTime()) / 1000);
var year
= Math
.floor(runTime
/ 86400 / 365);
runTime
= runTime
% (86400 * 365);
var month
= Math
.floor(runTime
/ 86400 / 30);
runTime
= runTime
% (86400 * 30);
var day
= Math
.floor(runTime
/ 86400);
runTime
= runTime
% 86400;
var hour
= Math
.floor(runTime
/ 3600);
runTime
= runTime
% 3600;
var minute
= Math
.floor(runTime
/ 60);
runTime
= runTime
% 60;
var second
= runTime
;
var shijiancha
= new Array(year
,month
,day
,hour
,minute
,second
)
return shijiancha
}
let shijiancha_a
= calculationTime(startTime
)
console
.log(shijiancha_a
)
转载请注明原文地址: https://lol.8miu.com/read-4428.html