Jeff's Blog

Random notes on programming, web design and computer repair

Set Environment Variable to the Date and Time

Set a variable to the current Date and Time in Batch file:

for /F "tokens=2,3,4 delims=/ " %%i in ('date/t') do set d=%%k%%i%%j
for /F "tokens=1,2,3 delims=:. " %%i in ('time/t') do set t=%%i%%j%%k
echo The date is %d% and the time is %t%