Y
Y
Yrets1692021-09-01 21:51:33
Python
Yrets169, 2021-09-01 21:51:33

How to set the system time?

Good afternoon, I found a script on the Internet that changes the system time

import datetime
time_tuple = (2012,  # Year
              9,  # Month
              6,  # Day
              0,  # Hour
              38,  # Minute
              0,  # Second
              0,  # Millisecond
              )
 
def _win_set_time(time_tuple):
    import win32api
    dayOfWeek = datetime.datetime(*time_tuple).isocalendar()[2]
    t = time_tuple[:2] + (dayOfWeek,) + time_tuple[2:]
    print(t)
    win32api.SetSystemTime(*t)
_win_set_time(time_tuple)


+3 or +2 (hours/hours) is added to the time depending on different dates and times, how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-09-01
@Yrets169

SetSystemTime() sets the time in UTC, and the tray clock shows it in the local time zone (which, moreover, may vary depending on the date and whether it was daylight saving time then).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question