Echo the date and time in a windows batch file

MY GOD!

you would think this was easy eh?

I found this link which states “setting the date and time into a variable in dos is relatively easy“.

hmmm..

here it is (this example is a wrapper for good ol’ ant) :

@echo off

call ..\\tools\\ant\\bin\\ant -f r2build\\build.xml %*

FOR /F "TOKENS=*" %%A IN ('DATE/T') DO SET today=%%A
FOR /F "TOKENS=*" %%A IN ('TIME/T') DO SET now=%%A

@echo.
@echo Build completed on %today% at %now%
@echo.
Share