javascript - How do i check inBetween time using time zone Moment -


i'm trying time in between it's not working. "not business time!"

 let currenttime = moment().tz('europe/london');       let opening = moment('9:00am', 'h:mma');       let closing = moment('7:00pm', 'h:mma');       console.log(currenttime);       console.log(opening);       console.log(closing);        if (currenttime.isbetween(opening,closing)) {        opentext = "it's business time!"      } else {        opentext = "not business time!"      } 

console output

moment.parsezone("2017-08-20t16:57:06.117+01:00") moment("2017-08-20t09:00:00.000") moment("2017-08-20t19:00:00.000") 

make sure lib version 2.9.0+ reference

make sure include:

  1. moment.js
  2. moment-timezone.js
  3. moment-timezone-with-data.js

working example: http://jsfiddle.net/guw1s31q/1/


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -