如何显示later.js text parser之后还剩多少时间应用?
例如,我想在setInterval
开始之前知道它。
const later = require('later');
later.date.localTime();
const schedule = later.parse.text('at 12:40');
later.setInterval(() => {
console.log('executed!');
}, schedule);
最佳答案
有.next()计算 future 发生情况的方法。
显示 future 发生的情况
输入:
console.log(later.schedule(schedule).next());
输出:
2017-11-28T12:40:00.000Z
显示 10 个 future 出现的情况
输入
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 ]
关于javascript - 显示应用later.js文本解析器后还剩下多少时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47507146/