繁体   English   中英

显示应用Later.js文本解析器后还剩下多少时间

[英]Show how much time is left after later.js text parser applied

应用Later.js文本解析器后,如何显示剩余时间?

例如,我想在setInterval开始之前知道它。

const later = require('later');

later.date.localTime();
const schedule = later.parse.text('at 12:40');

later.setInterval(() => {
    console.log('executed!');
}, schedule);

.next()方法来计算未来发生的事件。

显示未来发生的事情

输入:

console.log(later.schedule(schedule).next());

输出:

2017-11-28T12:40:00.000Z

显示10个未来事件

输入项

console.log(later.schedule(schedule).next(10));

输出量

[ 2017-11-28T12:40:00.000Z,
  2017-11-29T12:40:00.000Z,
  2017-11-30T12:40:00.000Z,
  2017-12-01T12:40:00.000Z,
  2017-12-02T12:40:00.000Z,
  2017-12-03T12:40:00.000Z,
  2017-12-04T12:40:00.000Z,
  2017-12-05T12:40:00.000Z,
  2017-12-06T12:40:00.000Z,
  2017-12-07T12:40:00.000Z ]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM