- time1的传参数类型是“2022-11-10 23:23:20”
点击查看代码
function times(time1) {
let now = new Date() //当前时间
let end = new Date(time1.replace(/-/g, '/')) // 到期时间
let nowTime = end.getTime() - now.getTime()
let oneDayTime = 24 * 60 * 60 * 1000
if (nowTime > 0) {
let Remainder = nowTime % oneDayTime //取余
return now.getTime() < end.getTime() - Remainder
} else {
return now.getTime() < end.getTime()
}
}
</details>
执行方法: times('2022-11-10 03:00:00')