【问题标题】:How do i check inBetween time using time zone Moment我如何使用时区时刻在时间之间签入
【发布时间】:2017-08-20 16:01:12
【问题描述】:

我试图在两者之间留出时间,但它不起作用。它总是说“不是工作时间!”

 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 a business time!"

    }

控制台输出

moment.parseZone("2017-08-20T16:57:06.117+01:00")
moment("2017-08-20T09:00:00.000")
moment("2017-08-20T19:00:00.000")

【问题讨论】:

    标签: javascript time momentjs


    【解决方案1】:

    确保你的lib版本是2.9.0+reference

    确保包括:

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

    工作示例: http://jsfiddle.net/guw1s31q/1/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-16
      • 2019-06-08
      • 1970-01-01
      • 2014-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多