Batch file datetime windows settings

梦想与她 提交于 2021-01-29 06:02:40

问题


Recently my windows was backed with image restore software to previous version, so I had to install everything from scratch.

What really stresses me is that script that had worked before now doesn't. It's related to dates and datetime.

My colleague tried to run .bat file and he was able to get appropriate date format.

I tried to copy all the windows 10 date settings and still it doesn't work. Any ideas how to solve this? My output is:

C:\Software\scripts>for /F "usebackq tokens=1,2 delims==" %i in (`wmic os get LocalDateTime /VALUE 2>NUL`) do if '.%i.' == '.LocalDateTime.' set ldt=%j
C:\Software\scripts>set ldt=~0,4ldt:~4,2ldt:~6,2

The script:

for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j 
set ldt=%ldt:~0,4%-%ldt:~4,2%-%ldt:~6,2%
PAUSE

来源:https://stackoverflow.com/questions/63584718/batch-file-datetime-windows-settings

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