Code: Select all
@ echo off
cls
for /f "tokens=3" %%G in ('reg query ^"HKEY_CURRENT_USER\Control Panel\International^" /v sTimeFormat ^| find ^"REG_SZ^"') do (
set time_format=%%G)
echo %time_format%
echo time format in registry
echo.
time/t
echo time from time/t command
echo.
echo %time%
echo time environment variable
echo.
echo ~ ~ ~
echo.
for /f "tokens=3" %%H in ('reg query ^"HKEY_CURRENT_USER\Control Panel\International^" /v sShortDate ^| find ^"REG_SZ^"') do (
set date_format=%%H)
echo %date_format%
echo date format in registry
echo.
date/t
echo date from date/t command
echo.
echo %date%
echo date environment variable
echo.
echo.
echo.
pause
Code: Select all
h:mm:ss
time format in registry
09:46 AM
time from time/t command
9:46:11.62
time environment variable
~ ~ ~
M/d/yyyy
date format in registry
Sat 11/09/2019
date from date/t command
Sat 11/09/2019
date environment variable
Press any key to continue . . .
time/t outputs a leading zero for hours and ends with am/pm
time variable outputs hundredths of seconds
date/t and date variable outputs day of the week
how could I reliably reformat the time and date despite the locale?
where is cmd.exe getting the format from?