如何使用时区Moment

时间:2017-08-20 16:01:12

标签: javascript time momentjs

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

 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")

1 个答案:

答案 0 :(得分:0)

确保您的lib版本为// SELECT THE KEY YOU NEED $result = mysqli_query($resDBCon, "SELECT * FROM keys WHERE Key = '$strKey'"); // LOOP ALL RESULTS AND ENTERING IN THE WHILE MEANS THAT THE KEY EXISTS while($row = mysqli_fetch_array($result) { // HERE YOU CHECK IF KEY WAS USED if($row['isUsed'] == 1) echo 'Key was used'; } reference

确保包括:

  1. moment.js
  2. 矩timezone.js
  3. 矩时区与 - data.js
  4. 工作示例: http://jsfiddle.net/guw1s31q/1/