Lodash - 日期

Lodash 提供了一个 now 函数来获取当前时间(以毫秒为单位)。

语法

_.now()

获取自 Unix 纪元(1970 年 1 月 1 日 00:00:00 UTC)以来经过的毫秒数的时间戳。

输出

  • (number) − 返回时间戳。

示例

var _ = require('lodash');
var result = _.now();
console.log(result);

将上述程序保存在tester.js中。运行以下命令执行该程序。

命令

\>node tester.js

输出

1601614929848