JSI Tip 8188. How can I retrieve the current time in numeric environment variables?


In tip 8187, I retrieved the current time into 2 digit (character) hour, minute, second, and hundredth of a second environment variables.

I have scripted NumbTime.bat to retrieve the current time into hour, minute, second, and hundredth of a second numeric environment variables.

The syntax for using NumbTime.bat is:

call NumbTime Hour Minute Second Hsec

Where:

Hour   is a call directed numeric environment variable that will contain the hour, 0-23.
Minute is a call directed numeric environment variable that will contain the minute, 0-59.
Second is a call directed numeric environment variable that will contain the second, 0-59.
Hsec   is a call directed numeric environment variable that will contain the hundredth of a second, 0-99.
NumbTime.bat contains:
@echo off
if \{%4\}==\{\} @echo Syntax NumbTime Hour Minute Second Hsec&goto :EOF
for /f "tokens=5-8 delims=:. " %%h in ('@echo.^|time') do (
 set /a %1=100%%h%%100
 set /a %2=100%%i%%100
 set /a %3=100%%j%%100
 set /a %4=100%%k%%100
)



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish