Change date and time format via command prompt

2019-07-14 18:57发布

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"

2条回答
Ridiculous、
2楼-- · 2019-07-14 19:24

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
查看更多
Explosion°爆炸
3楼-- · 2019-07-14 19:34

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

查看更多
登录 后发表回答