Skip to content Skip to sidebar Skip to footer

Subtract Minutes From Calculated Time Javascript

I need to subtract minutes from the calculated time var calculatedTime=11.30;// hours var subtractTime=40;//minutes var diff=calculatedTime - subtractTime;// How to do this ?? How

Solution 1:

Try this:

functionconverToMinutes(s) {
    var c = s.split('.');
    returnparseInt(c[0]) * 60 + parseInt(c[1]);
}

functionparseTime(s) {
    returnMath.floor(parseInt(s) / 60) + "." + parseInt(s) % 60
}
//var minutes = parseTime(EndTIme) - parseTime(StartTime);var timeToSubtract = 40;
var startTime = converToMinutes('11.30');
var converted = parseTime(startTime - timeToSubtract);
alert(converted);

Demo here

Post a Comment for "Subtract Minutes From Calculated Time Javascript"