Search code examples
fullcalendarmomentjstimepicker

Moment.js isAfter() is not a function


I'm using FullCalendar with jQuery timepicker to set the event.

I have 2 variables named timeDateInizio and timeDateFine.

Those two variables are string created by merging 2 other variables each, one for the YY:MM:dd and the other for hh:mm:ss

Then I have an if to check if timeDateInizio is after timeDateFine, and if it is a bootbox appear to signal an error. Here is the if: if (timeDateInizio.isAfter(timeDateFine)) {...}.

I receive these error when I get to the if: "Uncaught TypeError: timeDateInizio.isAfter is not a function."

Can someone help me solve this?


Solution

  • Does casting your variables into Moment objects solve your issue?

    if (moment(timeDateInizio).isAfter(moment(timeDateFine))) {...}.