How do I set the windows system clock to the right local time using C++?
-
28-09-2019 - |
Question
Right now I do something like this:
SYSTEMTIME st;
st.wHour = 6;
st.wMinute = 23;
BOOL result = SetSystemTime(&st);
The goal is to get it to show that exact time on my local machine. When I run the program it changes it to 8:23 instead of 6:23. How can I get it to show the correct local time?
Solution
SetSystemTime()
expects the provided time to be in UTC. If you want to set the time using the local time, use SetLocalTime()
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow