Change System DateTime Format c#

核能气质少年 提交于 2019-12-02 06:16:31

I tried manually changing the registry keys mentioned in your question.

Here's what I did:

  • Pressed Win+R and type 'regedit' to get the Registry Editor.
  • Navigated the tree to Computer → HKEY_CURRENT_USER → Control Panel → International.
  • Double clicked the 'sShortDate' entry and changed the value to 'yyyy/MM/dd'.

I then opened Windows Explorer and all of the dates were shown in the new format, so this is definitely the right place in the registry.

I then tried the code you supplied to modify the registry and it, too, is changing the date shown in Explorer.

So, this leads me to believe that the Windows taskbar clock does not react to changes to this setting. I confirmed this by killing and restarting 'explorer.exe' from the Task Manager. If you restart Explorer you too should see the change take effect.


Edit: there appears to be no facility in .NET for setting the locale settings directly. You can, however, use P/Invoke to set it via the C++ Win API which should then cause the system clock (and other applications) to be notified of the change. See this discussion.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!