To get the system boot time in TypeScript, you can use the os
module that comes with Node.js.
Here is the code:
index.ts171 chars6 lines
In the code above, first we import the os
module. Then we use the os.uptime()
method to get the uptime of the system in seconds. We then subtract the uptime from the current time (Date.now()
) to get the boot time of the system. We log the boot time to the console.
gistlibby LogSnag