Here is some JavaScript that will do what you are asking:
function minTommss(minutes){
var sign = minutes < 0 ? "-" : "";
var min = Math.floor(Math.abs(minutes));
var sec = Math.floor((Math.abs(minutes) * 60) % 60);
return sign + (min < 10 ? "0" : "") + min + ":" + (sec < 10 ? "0" : "") + sec;
}
Examples:
minTommss(3.5) // "03:30"
minTommss(-3.5) // "-03:30"
minTommss(36.125) // "36:07"
minTommss(-9999.999) // "-9999:59"
You could use moment.js durations, such as
moment.duration(1.234, 'minutes')
But currently, there's no clean way to format a duration in mm:ss like you asked, so you'd be re-doing most of that work anyway.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…