如何使用 C++ 将 Windows 系统时钟设置为正确的本地时间?

发布于 2024-09-06 19:38:38 字数 225 浏览 2 评论 0原文

现在我做了这样的事情:

    SYSTEMTIME st;

    st.wHour = 6;
    st.wMinute = 23;

    BOOL result = SetSystemTime(&st);

目标是让它在我的本地计算机上显示准确的时间。当我运行该程序时,它会将其更改为 8:23 而不是 6:23。我怎样才能让它显示正确的当地时间?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

装迷糊 2024-09-13 19:38:38

SetSystemTime() 期望提供的时间采用 UTC 格式。如果要使用当地时间设置时间,请使用 SetLocalTime()

SetSystemTime() expects the provided time to be in UTC. If you want to set the time using the local time, use SetLocalTime().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文