//判断某个时间是否在当前时间31天内
isInCurrentTime31Days () {
const dateStr = this.selectedTableInfo.createdAt
const givenDate = new Date(dateStr)
const now = new Date()
const diffTime = Math.abs(now - givenDate)
const diffDays = diffTime / (1000 * 60 * 60 * 24)
return diffDays < 31
}
//判断某个时间是否与当前时间是同月
isInCurrentMonthTime () {
const dateStr = this.selectedTableInfo.createdAt
const currentDate = new Date()
const checkDate = new Date(dateStr)
const currentYear = currentDate.getFullYear()
const currentMonth = currentDate.getMonth()
const checkYear = checkDate.getFullYear()
const checkMonth = checkDate.getMonth()
return (
checkYear === currentYear &&
checkMonth === currentMonth &&
checkDate < currentDate
)
}
js时间范围判断
于 2024-05-28 18:16:16 首次发布