I have a Date
object and I want to check if it’s tomorrow.
const dateToCheck: Date //Sat Jun 01 2024 09:00:00 GMT-0700
I calculated tomorrow like this:
const tomorrow = moment().add(1, 'day')
The start and end of tomorrow are found like this:
tomorrow.startOf('day') //Sat Jun 01 2024 00:00:00 GMT-0700
tomorrow.endOf('day') //Sat Jun 01 2024 23:59:59 GMT-0700
When I try to determine if the date I’m checking is tomorrow, it’s false
:
var isTomorrow = moment(dateToCheck).isBetween(
tomorrow.startOf('day'),
tomorrow.endOf('day'),
)
console.log(isTomorrow) //false
As far as I can tell, isTomorrow
should be true
because Sat Jun 01 2024 09:00:00
is between Sat Jun 01 2024 00:00:00
and Sat Jun 01 2024 23:59:59
.
Any idea what I’m doing wrong?