/**
* 截至日期格式示例:2022-06-02 15:00:00
* true:到了截止时间,false:未到截止时间
*/
export function getDeadline(str) {
const myDate = new Date()
const year = myDate.getFullYear()
const mon = (myDate.getMonth() + 1).toString().padStart(2, '0')
const date = myDate.getDate().toString().padStart(2, '0')
const hour = myDate.getHours().toString().padStart(2, '0')
const minutes = myDate.getMinutes().toString().padStart(2, '0')
const seconds = myDate.getSeconds().toString().padStart(2, '0')
const now = `${year}-${mon}-${date} ${hour}:${minutes}:${seconds}`
const newDate = now.replace(/-/g, '/')
const time = new Date(newDate).getTime()
const sureTime = new Date(str.replace(/-/g, '/')).getTime()
return time >= sureTime
}
标签:const,myDate,padStart,JS,toString,new,Date,时间,截止
From: https://www.cnblogs.com/jia-zq/p/17161617.html