使用Warp js的Javascript Warp Time

时间:2016-11-04 02:27:53

标签: javascript

我正在开展一个项目,我需要向前和向后操纵时间速度。这个模块看起来就像我需要的那样,但是我无法让它运转起来:

https://github.com/mattbradley/warpjs/blob/master/README.md

任何帮助表示赞赏

    <html>
        <head>
        </head>

    <body>
        <script src="jquery.min.js"></script>
        <script src="warp.js"></script>


        <div id="container"></div>
        <span id="info"></span><br>
        <span id="time"></span>
        <span id="time2"></span>

        <script>


      setInterval(function() {
        var now = new Date;
        now = Date.warp.clock(true);
        //now = Date.warp.speed(2); // DOESNT WORK?

        var dateD = [now.getMonth() + 1,now.getDate(),now.getFullYear()];
        var dateE = [now.getHours(),now.getMinutes(),now.getSeconds()];
        var MDY = dateD.join("/");
        var HMS = dateE.join(":");
        time.innerHTML = (MDY);
        time2.innerHTML = (HMS);

      }, 20);


        </script>

    </body>

    </html>

1 个答案:

答案 0 :(得分:1)

wrap是一个静态方法,它不会返回任何值(返回undefined

setInterval(function() {
  Date.warp.speed(3);
  var now = new Date;

  var dateD = [now.getMonth() + 1, now.getDate(), now.getFullYear()];
  var dateE = [now.getHours(), now.getMinutes(), now.getSeconds()];
  var MDY = dateD.join("/");
  var HMS = dateE.join(":");
  time.innerHTML = (MDY);
  time2.innerHTML = (HMS);

}, 1000);

演示:Fiddle