Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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))) {...}.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading