Tag: unix timestamp

Moment.js unix时间戳与时代时间戳不匹配

我在node.js中使用了moment.js的unix()函数,它返回时间戳,当我把这个时间戳与时间戳记( https://www.epochconverter.com/ )相匹配时, 20秒 矩()。UNIX() 所以任何人都可以帮助。

Node.js将datestring转换为unix时间戳

我试图在Node.js中将datestring转换为unix时间戳。 我的代码在我的客户端完美工作,但是当我在我的服务器上运行它我得到一个错误: (node:19260)UnhandledPromiseRejectionWarning:未处理的承诺拒绝(拒绝ID:1):TypeError:input.substring不是函数 我的代码: function dateParser(input) { // function is passed a date and parses it to create a unix timestamp // removing the '.000' from input let finalDate = input.substring(0, input.length – 4); return new Date(finalDate.split(' ').join('T')).getTime(); } 我的input示例为2017-09-15 00:00:00.000 那么,为什么上述工作在我的客户端,但不是在节点,以及如何复制节点中的function?