Reputation: 283
I need to compare two values, as you see in my code below.
Point is that they are in different formats, and i need them to compare.
Here is my code(daysToLeave is allways number 1-3 - this value match 1-3 days):
const tomorrow = new Date();
const tmp = tomorrow.getDate() + daysToLeave;
tomorrow.setDate(tmp);
console.log("eventDate.date", eventDate?.date);
console.log("tommorrow", tomorrow);
if (eventDate?.date < tomorrow) {
console.log("success");
}
Upvotes: 0
Views: 141
Reputation: 204
use moment and .diff().
//Determine the unit of difference between
const type = ["years","months","weeks","days","hours","minutes"]
moment(tomorrow).diff(eventDate?.date.toDate(), type[3])
Upvotes: 1