Skip to content

Instantly share code, notes, and snippets.

@kleo
Created August 6, 2017 23:19
Show Gist options
  • Select an option

  • Save kleo/25899171b2807fcf21d52fb55c5d826a to your computer and use it in GitHub Desktop.

Select an option

Save kleo/25899171b2807fcf21d52fb55c5d826a to your computer and use it in GitHub Desktop.
Windows batch file timer (credits: https://stackoverflow.com/a/9935540/)
@echo off
setlocal EnableDelayedExpansion
set "startTime=%time: =0%"
set /P "=Any process here..."
set "endTime=%time: =0%"
rem Get elapsed time:
set "end=!endTime:%time:~8,1%=%%100)*100+1!" & set "start=!startTime:%time:~8,1%=%%100)*100+1!"
set /A "elap=((((10!end:%time:~2,1%=%%100)*60+1!%%100)-((((10!start:%time:~2,1%=%%100)*60+1!%%100)"
rem Convert elapsed time to HH:MM:SS:CC format:
set /A "cc=elap%%100+100,elap/=100,ss=elap%%60+100,elap/=60,mm=elap%%60+100,hh=elap/60+100"
echo Start: %startTime%
echo End: %endTime%
echo Elapsed: %hh:~1%%time:~2,1%%mm:~1%%time:~2,1%%ss:~1%%time:~8,1%%cc:~1%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment