Batch Script Date and Time
Date and Time
The date and time in Batch Scripting have the following two basic commands for retrieving the date and time of the system.
date command gets the system date.
The output is different depending on the localization of the operating system.
time command sets or displays the time.
Extract current day/month/year in a locale-indipendent way
The following batch code returns the components of the current date in a locale-independent way and stores day, month and year in the variables
for /F "skip=1 delims=" %%F in ('
wmic PATH Win32_LocalTime GET Day^,Month^,Year /FORMAT:TABLE
') do (
for /F "tokens=1-3" %%L in ("%%F") do (
echo Current day : %CurrDay%
echo Current month: %CurrMonth%
echo Current year :%CurrYear%
Current day : 20
Current month: 07
Current year :2022