Get Day, Month, and Year |
The following works for both "dd/mm/yyyy" and "mm/dd/yyyy":
@echo off @rem NEWSGROUP: microsoft.public.win2000.cmdprompt.admin @rem SUBJECT : How can i to get the current month in commandline? @rem WHEN/WHO : Mar 14 2001, 9:05 pm post by Michael (maj0) :: Tokenise date into dd mm and yy independent of locale for /f "tokens=2-4 delims=.:/-, " %%i in ("%date%") do ( for /f "tokens=2-4 delims=/-,() skip=1" %%l in ('echo.^|date') do ( set %%l=%%i set %%m=%%j set %%n=%%k)) :: Lets see what we got! for %%i in (dd mm yy) do set %%i
You may also wish to have a look at the "Get File Safe Dates and Times" section.