get system boot time in minutes in typescript

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.ts
import os from 'os';

const uptime = os.uptime(); // uptime in seconds
const minutes = Math.floor(uptime / 60); // uptime in minutes

console.log(`System has been running for ${minutes} minutes.`);
198 chars
7 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