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

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -