To get the system boot time in minutes in TypeScript with Node.js, we can use the built-in os
module. Here's an example of how to do it:
index.ts198 chars7 lines
We first import the os
module. Then we use the os.uptime()
function to get the uptime of the system in seconds. We divide this value by 60 to get the uptime in minutes, rounding down to the nearest minute using Math.floor()
. Finally, we log the uptime in minutes to the console.
Note that this will give you the time since the system was last booted, not the time since the current user logged in.
gistlibby LogSnag