I try to check if a certain time in h:mm is before another time with same format. However, the console shows me either an error saying isBefore is not a function or it always print false. I use this code in Ionic 3/Angular.
If I code as follows, the console prints false. I tried different arguments instead of hour.
var start_time = moment('20:00', 'h:mm').format('LT');
var last_time = moment('21:59', 'h:mm').format('LT');
var check_last = moment(start_time).isBefore(last_time, 'hour');
console.log(check_last);
If I code as follows. As found on the link below. The console give me the error is
var start_time = moment('20:00', 'h:mm').format('LT');
var last_time = moment('21:59', 'h:mm').format('LT');
var check_last = start_time.isBefore(last_time, 'hour');
console.log(check_last);
Moment.js isBefore function not working as expected
On the official website of momentjs I didn't figure out how to compare two times. Can you please give me support?