get system boot time in milliseconds in typescript

To get the system boot time in milliseconds in typescript, we can make use of the 'systeminformation' library which provides various system information. To install the library, run the following command:

index.ts
npm install systeminformation
30 chars
2 lines

Then, we can use the systeminformation.uptime() function to get the system uptime in seconds and multiply by 1000 to get the uptime in milliseconds. Here's how we can do it:

index.ts
import si from 'systeminformation';

si.uptime((uptime) => {
    const bootTimeInMillis = uptime * 1000;
    console.log(`System boot time: ${bootTimeInMillis} milliseconds`);
})
179 chars
7 lines

Using the above code, we can get the system boot time in milliseconds.

gistlibby LogSnag