Change date and time format via command prompt

不打扰是莪最后的温柔 提交于 2019-12-23 17:43:25

问题


I was just wondering, in Windows 7 and above, is it possible to change the way dates and times are displayed via the command prompt? Yes, I'm in the U.S. but I like doing things the European way:

(In Clock/Language/Region)

Short Date: Set as "d/M/yyyy"

Long Date: Set as "dddd, d MMMM yyyy"

Short Time: Set as "HH:mm"

Long Time: Set as "HH:mm:ss"


回答1:


Yes, it's possible e.g. using reg add command.
Check the HKEY_CURRENT_USER\Control Panel\International registry key:

reg query "HKCU\Control Panel\International"

For instance, query Short Time format:

reg query "HKCU\Control Panel\International" /V sShortTime

and set it to desired value:

reg add "HKCU\Control Panel\International" /V sShortTime /T REG_SZ /D HH:mm /F

If value name or data contains spaces, use double quotes (surrounding double quotes would not be written to registry):

reg add "HKCU\Control Panel\International" /V sShortTime /T REG_SZ /D "HH:mm" /F



回答2:


X:>echo %date:~10,4%%date:~4,2%%date:~7,2% 20181110



来源:https://stackoverflow.com/questions/36726738/change-date-and-time-format-via-command-prompt

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