Lodash _.now() method is used to get the timestamp of the number of milliseconds that have elapsed since the Unix epoch (1 January 1970 00:00:00 UTC).
Syntax:
_.now();
Parameters:
This method does not accept any parameter.
Return Value:
This method returns the timestamp.
Example 1: In this example, we are printing the time stamp in the console by the use of the lodash _.now() method.
Javascript
const _ = require( 'lodash' );
console.log(_.now());
|
Output:
1599545119753
Example 2: In this example, we are printing the time stamp in the console by the use of the lodash _.now() method.
Javascript
const _ = require( 'lodash' );
function print() {
setTimeout(() => {
console.log(
`Current timestamp is: ${_.now()}`)
}, 10)
}
_.times(5, print)
console.log( "Type of timestamp is: " ,
typeof (_.now()))
|
Output:
Type of timestamp is: number
Current timestamp is: 1599546710915
Current timestamp is: 1599546710916
Current timestamp is: 1599546710916
Current timestamp is: 1599546710916
Current timestamp is: 1599546710916
Note: This will not work in normal JavaScript because it requires the lodash library to be installed.
Last Updated :
30 Oct, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...