You can use the systeminformation
package in Node.js to get the system boot time in seconds. Here's an example:
index.tsx267 chars9 lines
The system()
method returns a promise that resolves to an object containing various system information, including the bootTime
property, which is the timestamp of the system boot time. We calculate the difference between the current time and the boot time and convert it to seconds. The result is then logged to the console.
gistlibby LogSnag