Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
June 23, 2004
Using a technique similar to the Universal Date Parser, I have scripted WhatTime.bat to retrieve the current time.
The syntax for using WhatTime.bat is:
call WhatTime Hour Minute Second Hsec
Where:
Hour is a call directed environment variable that will contain the 2 digit hour, 00-23.Minute is a call directed environment variable that will contain the 2 digit minute, 00-59.Second is a call directed environment variable that will contain the 2 digit second, 00-59.Hsec is a call directed environment variable that will contain the 2 digit hundredth of a seconds, 00-99.
NOTE: See How can I retrieve the current time in numeric environment variables?
WhatTime.bat contains:
@echo offif {%4}=={} @echo Syntax WhatTime Hour Minute Second Hsec&goto :EOFfor /f "tokens=5-8 delims=:. " %%h in ('@echo.^|time') do ( set /a %1=100%%h%%100 + 100 set %2=%%i set %3=%%j set %4=%%k)call set %1=%%%1:~1^,2%%
You May Also Like