Posted by SpywareDr on February 18, 2011 at 20:02:31:
In Reply to: dos diary posted by fuzzbrain11 on February 18, 2011 at 18:18:58:
-------------------------------[cut here]-------------------------------
@echo off
:GetDate
 for %%x in (mm dd yr cc yy) do set %%x=
 for /F "tokens=1-3 delims=/" %%A in ('echo %date%') do (
   set mm=%%A
   set dd=%%B
   set yr=%%C
 )
 set cc=%yr:~0,2%
 set yy=%yr:~2,2%
 echo %mm%/%dd%/%yr%
:End
-------------------------------[cut here]-------------------------------
The above "getdate.bat" sets the following five environment variables:
mm = 2-digit month
dd = 2-digit day
yy = 2-digit year
yr = 4-digit year
cc = 2-digit century (the left two digits of the 4-digit year)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And while we're at it, might as well go ahead and get the time:
-------------------------------[cut here]-------------------------------
@echo off
:GetTime
 for %%x in (hr mn sc hn) do set %%x=
 for /F "tokens=1-4 delims=:." %%A in ('echo %time%') do (
   set hr=%%A
   set mn=%%B
   set sc=%%C
   set hn=%%D
 )
 if %hr% LSS 10 set hr=0%hr%
 echo %hr%:%mn%:%sc%.%hn%
:End
-------------------------------[cut here]-------------------------------
The above "gettime.bat" sets the following four environment variables:
hr = 2-digit hour
mn = 2-digit minute
sc = 2-digit second
hn = 2-digit hundredths of a second
Note: This is military time, 00:00:00.00 through 23:59:59.99, (i.e., no "AM" or "PM" needed).