javascript - Division of decimal part of number only -
is there anyway divide decimal of number instead of whole number. if have number 3.99 want divide decimal 1.66667. want because 3.99 supposed equal 3 minutes 59 seconds, rather have read 3.59 instead of 3.99.
this code have return time now, btw returning time program telling how time till due. used full 2 decimal number format.
function getdiff(dt) { smins = " min"; shours = " hours"; sdays = " days"; ssecs = " secs"; if (math.abs(datediff("s", now, dt)) < 86400) { if (math.abs(datediff("s", now, dt)) <= 3600) { return ((math.floor(math.abs( datediff("s", now, dt) / 60) * 100) / 100 ).tofixed(2) + smins); } else { return ((math.floor(math.abs( datediff("s", now, dt) / 3600) * 100) / 100 ).tofixed(2) + shours); } } else { return ((math.floor(math.abs( datediff("s", now, dt) / 86400) * 100) / 100 ).tofixed(2) + sdays); } }
you minutes - 3, , 0.99 minutes 0.99*60 seconds , append minutes return "3"+"."+"59" + smins
but not recommended display "." case....
Comments
Post a Comment