I have many script that get data and time in this way
Code: Select all
SET G=%DATE:~0,2%
SET M=%DATE:~3,2%
SET Y=%DATE:~6,4%
FOR /F "tokens=1 delims=." %%G IN ('TIME /T') DO SET HH=%%G
SET MM=%TIME:~3,2%
SET SS=%TIME:~6,2%
SET DD=%Y%%M%%G%
SET DD0=%Y%-%M%-%G%
SET DD1=%G%/%M%/%Y%
SET ORA=%HH%%MM%
SET ORA1=%HH%.%MM%.%SS%
or
CALL :sub_routine file.txt
Code: Select all
:sub_routine
SET start=%time%
SET shh=%start:~0,2%
SET smm=%start:~3,2%
SET sss=%start:~6,2%
SET sms=%start:~9,2%
SET DateTime2=%date% %shh%.%smm%.%sss%.%sms%
FOR /f "tokens=1-7 delims=/. " %%a in ("%Datetime2%") do (set "H=0%%d" &call set "DateTime3=%%c-%%b-%%a %%H:~-2%%:%%e:%%f.%%g")
FOR /f "tokens=1-7 delims=/. " %%a in ("%~t1") do (set "H=0%%d" &call set "FileDateTime=%%c-%%b-%%a %%H:~-2%%:%%e:00.00")
I must migrate from Microsoft Server 2003 with Italy regional settings (18/04/2013 15:40:00) to Microsoft Server 2008 with english regional settings (4/18/2013 3:40:00 pm) and I don't want use anymore variable %date% and %time% to avoid this problem.
There is a "universal" way to get this information indipendent from localization? (also for get created date of a file)
Best Regards