Getting startup time in Windows 10 doesn't give always the same time

Viewed 1878

I'm using this python (3.5) code to check windows startup time but it gives me a different time from the time I get using the shell command "systeminfo"

  • systeminfo: 9:15:23
  • python code: 9:14:42

Not happy with that, the python code is giving different times in itself! It started giving me 9:14:42, and right now it gives me 9:15:19, it's been adding a second to the boot time every 10 seconds or so.

I give you the code:

import datetime
import win32api

s = win32api.GetTickCount()
t = datetime.datetime.now()
st = datetime.timedelta(milliseconds=s)
bt = t-st
boot = "Boot time was around {}:{}:{}".format(bt.hour, bt.minute, bt.second)
print(boot)

I'm starting to think about calling the systeminfo command from python and just show the time it gives me.

1 Answers
Related