<span style="white-space:pre"> </span>function timeDefference(startTime, endTime) {
var t1 = new Date(startTime);
var t2 = new Date(endTime);
if (t1.getFullYear() - t2.getFullYear() > 0) {
var result = t1.getFullYear() - t2.getFullYear();
alert(result+"year")
return;
}
if (t1.getMonth() - t2.getMonth() > 0) {
var result = t1.getMonth() - t2.getMonth();
alert(result+"mounth")
return;
}
if (t1.getDate() - t2.getDate() > 0) {
var result = t1.getDate() - t2.getDate();
alert(result+"date")
return;
}
if (t1.getHours() - t2.getHours() > 0) {
var result = t1.getHours() - t2.getHours();
alert(result+"hour")
return;
}
if (t1.getMinutes() - t2.getMinutes() > 0) {
var result = t1.getMinutes() - t2.getMinutes();
alert(result+"minutes")
return;
}
return "刚刚"
}
js返回两个时间戳只差
最新推荐文章于 2024-08-27 15:36:53 发布