Outils pour utilisateurs

Outils du site


informatique:microsoft:windows:date

date

Afficher la date au format yyyy-mm-dd:

for /F "tokens=1,2,3 delims=/" %a IN ('echo %date%') DO @echo %c-%b-%a

Stocker dans une valeur la date :

for /F "tokens=1,2,3 delims=/" %a IN ('echo %date%') DO set TODAY=%c-%b-%a

Pour afficher le jour de la semaine (lundi, mardi, mercredi…)

@echo off

set /a J=1%DATE:~0,2% - 100
set /a M=1%DATE:~3,2% - 100
set /a A=%DATE:~6,4%
set /a N=((1461 * (%A% + 4800 + (%M% - 14) / 12)) / 4 + (367 * (%M% - 2 - 12 * ((%M% - 14) / 12))) / 12 - (3 * ((%A% + 4900 + (%M% - 14) / 12) / 100)) / 4 + %J% - 32075) %% 7

if %N%==0 set JOUR=Lundi
if %N%==1 set JOUR=Mardi
if %N%==2 set JOUR=Mercredi
if %N%==3 set JOUR=Jeudi
if %N%==4 set JOUR=Vendredi
if %N%==5 set JOUR=Samedi
if %N%==6 set JOUR=Dimanche

echo. & echo Nous sommes %JOUR% ... & echo.
informatique/microsoft/windows/date.txt · Dernière modification: 2018/09/06 19:10 (modification externe)