"moment js - check if a date is today or in the future" Code Answer

5

after reading the documentation: http://momentjs.com/docs/#/displaying/difference/, you have to consider the diff function like a minus operator.

                   // today < future (31/01/2014)
today.diff(future) // today - future < 0
future.diff(today) // future - today > 0

therefore, you have to reverse your condition.

if you want to check that all is fine, you can add an extra parameter to the function:

moment().diff(specialto, 'days') // -8 (days)
By mythicalprogrammer on March 22 2022

Answers related to “moment js - check if a date is today or in the future”

Only authorized users can answer the Search term. Please sign in first, or register a free account.