List of Examples for moment.js

1. To compare if time isBefore another time

time1 = 2014-01-01 1:25 pm
time2 = 2014-01-01 4:25 pm; is this time between time1 and time2?
time3 = 2014-01-01 5:25 pm

if (
moment(“2014-01-01 4:25 pm”,’YYYY-MM-DD HH:mm a’).isAfter(moment(“2014-01-01 1:25 pm”,’YYYY-MM-DD HH:mm a’))
&&
moment(“2014-01-01 4:25 pm”,’YYYY-MM-DD HH:mm a’).isBefore(moment(“2014-01-01 5:25 pm”,’YYYY-MM-DD HH:mm a’))
){
alert(‘in between’);
}

Tags:

Comments are closed.