This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableExtensions EnableDelayedExpansion | |
:: Use WMIC to retrieve date and time in a consistent format | |
for /f "tokens=2 delims==," %%x in ('wmic os get localdatetime /value') do set datetime=%%x | |
:: Extract the date in YYYYMMDD format | |
set "year=!datetime:~0,4!" | |
set "month=!datetime:~4,2!" | |
set "day=!datetime:~6,2!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableDelayedExpansion | |
:: Get today's date in DD-MM-YYYY format | |
for /f "tokens=1-3 delims=/" %%a in ('date /t') do ( | |
set _day=%%a | |
set _month=%%b | |
set _year=%%c | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
:: Get today's date in the format MM-DD-YYYY | |
for /f "tokens=2 delims==" %%I in ('"wmic os get localdatetime /value"') do set dt=%%I | |
set year=%dt:~0,4% | |
set month=%dt:~4,2% | |
set day=%dt:~6,2% | |
set today=%month%-%day%-%year% |