loading...

re: Vanilla JavaScript Check if Date is in the Past VIEW POST

FULL DISCUSSION
 

Just a point - your routine has a side effect of actually modifying the date you passed in... Seems unwise. Perhaps:

dateInPastArrow = (firstDate, secondDate) =>
  new Date(firstDate).setHours(0, 0, 0, 0) <= new Date(secondDate).setHours(0, 0, 0, 0); 
 

Also, shouldn't the comparison operator be just less than? If it's equal it's not past but present (or, to be more precise concurrent with the second date, since that could be any point in time)

code of conduct - report abuse