If the value is < 10, then you need to Left Pad with "0".
As an alternate to using @DanThomas' great Plugin, here is a JavaScript that converts seconds to HH:MM:SS. You could easily mod to output only HH:MM.
Script: Convert Seconds to HH:MM:SS<.nnn>
Seconds can be formatted to 0 or n decimals
Requires the KM Variable "TIME__ElapsedSeconds" to be set in KM Macro before calling script. Also, a KM Variable "TIME__Decimals" can be set to the number decimals to show in the seconds (default is 0).
Example Results
08:25:07
08:25:06.63
JavaScript
'use strict';
(function () { // Function is auto-run when script is executed
/*
---
Convert seconds to HH:MM:SS.nnn
---
DATE: 2016-12-02
AUTHOR: @JMichaelTX
REF:
• Convert seconds to HH-MM-SS with JavaScript? - Stack Overflow
• stackoverflow.com, general
• http://stackoverflow.com/a/38467919/915019
---
*/
// --- GET DATA FROM KM VARIABLES ---
var kmeApp = Application("Keyboard Maestro Engine");
// -- DEFAULT VALUES APPEAR AFTER THE "||" --
var elapsedSeconds = kmeApp.getvariable('TIME__ElapsedSeconds');
var decimals = kmeApp.getvariable('TIME__Decimals') || 0;
// --- BREAKDOWN SECONS INTO HOURS, MINUTES, SECONDS ---
var hours = parseInt( elapsedSeconds / 3600 ) % 24;
var minutes = parseInt( elapsedSeconds / 60 ) % 60;
var seconds = elapsedSeconds % 60;
// --- ROUND SECONDS TO REQUIRED DECIMALS ---
seconds = round(seconds,decimals);
// --- BUILD TIME STRING, PADDED WITH "0" ---
var timeStr = (hours < 10 ? "0" + hours : hours)
+ ":" + (minutes < 10 ? "0" + minutes : minutes)
+ ":" + (seconds < 10 ? "0" + seconds : seconds);
return timeStr
//~~~~~~~~~~~~~ END OF MAIN SCRIPT ~~~~~~~~~~~~~~~~~~~~~~~~~~~
// --- ROUND USING ACCURATE METHOD ---
function round(value, decimals) {
return Number(Math.round(value+'e'+decimals)+'e-'+decimals);
}
})();