time calculation
Moderator: DosItHelp
time calculation
I am just wondering how to deduct time that said I have to record a time and after some task I need to record time again...I can do upto that but now I need to find out the time difference....that is for the time needed to do that some task...any help hint would be appreciated
Re: time calculation
Hi eamjam,
use the %time% and calculate the seconds since 0:00.
Sample.
jeb
use the %time% and calculate the seconds since 0:00.
Sample.
Code: Select all
call :timeToMs ms_start "%start%"
call :timeToMs ms_end "%end%"
echo %start%=%ms_start%ms
echo %end%=%ms_end%ms
set /a diff_ms=ms_end-ms_start
echo diff=%diff_ms%ms
goto:eof
::::::::::::::::::.
:timeToMs <resultVar> <time>
::: convert a time (in normal 24h representation of the civilized world) to milli seconds from 0:00
SETLOCAL
FOR /F "tokens=1,2,3,4 delims=:,.^ " %%a IN ("%~2") DO (
set /a ms=^(^(^(30%%a%%100^)*60+7%%b^)*60+3%%c-42300^)*1000+^(1%%d0 %% 1000^)
)
(
ENDLOCAL
set %~1=%ms%
)
jeb