Wednesday, 8 November 2017

Windows Batch for getting today's date

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 (
        set CurrDay=0%%L
        set CurrMonth=0%%M
        set CurrYear=%%N
    )
)
set dd=%CurrDay:~-2%
set mm=%CurrMonth:~-2%
set yyyy=%CurrYear%

set today=%CurrYear%%CurrMonth:~-2%%CurrDay:~-2%

No comments:

Post a Comment