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:
- moment.js
- moment-timezone.js
- moment-timezone-with-data.js
working example: http://jsfiddle.net/guw1s31q/1/
Comments
Post a Comment