Created
November 3, 2010 00:47
-
-
Save santa4nt/660615 to your computer and use it in GitHub Desktop.
Parse the output of `DATE /T` and return it in MMDDYYYY format.
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 | |
:: sample usage | |
call:getMMDDYYYY _DATE | |
echo _DATE: %_DATE% | |
goto:eof | |
:: ----------------------------------------------------------------------------- | |
:: The "function" | |
:: ----------------------------------------------------------------------------- | |
:getMMDDYYYY | |
setlocal | |
for /f "tokens=1* " %%A in ('date /t') do set _cdate=%%B | |
for /f "tokens=1,2 eol=/ delims=/ " %%A in ('date /t') do set _mm=%%B | |
for /f "tokens=1,2 eol=/ delims=/" %%A in ('echo %_cdate%') do set _dd=%%B | |
for /f "tokens=2,3 delims=/ " %%A in ('echo %_cdate%') do set _yyyy=%%B | |
( endlocal | |
set %~1=%_mm%%_dd%%_yyyy% | |
) | |
goto:eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment