[SOLVED] Make Minutes & Seconds output 2 Digits
Posted: 20 May 2023 03:46
Good morning,
It has been a LONG time since I was here last due to health issues and I have a problem which I just can't seem to solve.
The below works great, except I would like the Minutes & Seconds to show as 2 digits instead of one. The program will run no longer than say 15 minutes so Hours are NOT an issue.
Stay SAFE, Best Regards, Paul.
It has been a LONG time since I was here last due to health issues and I have a problem which I just can't seem to solve.
The below works great, except I would like the Minutes & Seconds to show as 2 digits instead of one. The program will run no longer than say 15 minutes so Hours are NOT an issue.
Code: Select all
@echo off
setlocal EnableDelayedExpansion
for /f "skip=1 tokens=*" %%i in ('"PowerShell Get-Date"') do (set "[ST]=%%i")
... CODE HERE ...
Call :Timer
echo. & echo ^>Press ANY key to EXIT . . . & pause >nul & Exit
:Timer
for /f "skip=1 tokens=*" %%i in ('"PowerShell Get-Date"') do (set "[ET]=%%i")
set [T]=PowerShell -Command "&{$ST = [DateTime]::Parse('%[ST]%'); $ET = [DateTime]::Parse('%[ET]%'); echo (-Join( $D = ($ET - $ST).TotalSeconds));}"
for /f "delims=" %%i in ('%[T]%') do (set "[T]=%%i")
set /a [Minutes]=%[T]% / 60
set /a [Seconds]=%[T]%-%[Minutes]% * 60
echo Runtime: %[Minutes]% Minutes - %[Seconds]% Seconds
Exit /b