how to use the now function from lodash in javascript

The now function from Lodash library can be used to get the current timestamp in milliseconds. Here's an example of how to use now:

index.tsx
const _ = require('lodash');
const currentTimestamp = _.now(); // get current timestamp in milliseconds
console.log(currentTimestamp); // outputs something like 1614499557754
175 chars
4 lines

Alternatively, you can also use the native JavaScript Date.now() method to achieve the same result:

index.tsx
const currentTimestamp = Date.now();
console.log(currentTimestamp); // outputs something like 1614499557754
108 chars
3 lines

Both _.now() and Date.now() return the number of milliseconds since the Unix epoch (January 1, 1970, 00:00:00 UTC).

related categories

gistlibby LogSnag