The
process.uptime() method is an inbuilt application programming interface of the process module which is used to get the number of seconds the Node.js process is running.
Syntax:
process.uptime();
Parameters: This method does not accept any parameter.
Return Value: It returns a floating-point number specifying the number of seconds the Node.js process is running.
Below examples illustrate the use of process.uptime() method in Node.js:
Example 1:
Output:
0.0842063
Example 2:
Output:
the number of seconds the Node.js process is running: 0.077 seconds
the number of seconds the Node.js process is running: 0.087 seconds
In whole seconds: 0 seconds
Note: The above program will compile and run by using the
node filename.js command.
Reference: https://nodejs.org/api/process.html#process_process_uptime