I have a curTime
variable that is the current time using new Date()
and a pwChangeDate
value called from the backend data.
let curTime = new Date(); // Thu Oct 27 2022 15:02:34 GMT+0900
const pwDate = new Date(pwChangeDate) // Thu Oct 20 2022 13:51:57 GMT+0900
At this time, when pwDate
passes 90 days based on curTime
, I want to display an alert saying "90 days have passed." and when 83 days have passed, "7 days left out of 90 days." I want to display an alert.
but if i use my code it doesn't work how can i fix it?
const pwChangeDate = cookie.get('pwChangeDate');
const pwDate = new Date(pwChangeDate)
if (curTime.getDate() >= pwDate.getDate() - 90) {
alert('90 days have passed.')
}
if (curTime.getDate() >= pwDate.getDate() - 7) {
alert('7 days left out of 90 days..')
}