To get the uptime of the system, you can use the uptime() method from the os module in Node.js.
/* Get uptime of system Node.js */
// import os module
const os = require("os");
// get the uptime of system
const uptime = os.uptime(); // 22345
- The method returns the uptime of the system or time awake in
seconds.
See the above code live in repl.it.