I have a timestamp like new Date('2017-07-03T16:00:00.000')
I need to compare this date to the current date (new Date()
without arguments) and be able to tell whether at least one day has passed by date.
The time of the day does not play a role.
Here are a few examples:
Example 1
Old datetime: 2017-07-02T20:00:00.000
Current datetime: 2017-07-03T16:00:00.000
Returns true
because the old date was 2nd of July 2017, the current one is 3rd of July 2017.
Example 2
Old datetime: 2017-07-02T20:00:00.000
Current datetime: 2017-07-02T22:00:00.000
Returns false
because the old date was 2nd of July 2017 and the current one is 2nd of July 2017.
Example 3
Old datetime: 2017-07-02T20:00:00.000
Current datetime: 2017-07-04T22:00:00.000
Returns true
because multiple days have passed since the 2nd of July 2017.
I can't come up with a simple way to do this without messing with the calendar (month-& year transitions, leapyear etc.) itself. Can you enlighten me?