Format date (horodatage)

echo date_av : %date%

rem Permet de changer le format de date pour le current user
reg add « HKCU\Control Panel\International » /v sShortDate /d « dd-MM-yyyy » /f
echo date_ap : %date%
for /F « tokens=1-4 delims=- » %%a in (‘echo %date:~0,10%’) do set w_date=%%c%%b%%a
echo w_date : %w_date%

set horo=%w_date%_%w_time%
rem Horodatage d’un fichier log
set f_log=%d_log%\%horo%_%TOM_JOB%.log

On peut aussi changer temporairement le format de date.

rem save the existing format definition
for /f "skip=2 tokens=3" %%a in ('reg query "HKCU\Control Panel\International" /v sShortDate') do set FORMAT=%%a
rem set ISO specific format definition
reg add "HKCU\Control Panel\International" /v sShortDate /t REG_SZ /f /d yyyy-MM-dd 1>nul:
rem query the date in the ISO specific format 
set ISODATE=%DATE%
rem restore previous format definition
reg add "HKCU\Control Panel\International" /v sShortDate /t REG_SZ /f /d %FORMAT% 1>nul:

 

 

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *