问题
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