javascript - How do I make sure my function works for my variable? -
function numbertotime(num){ var d = 0, h = 0, m = 0; var numtominutes = num*60; while(numtominutes > 59){ numtominutes -= 60; h++; if(h > 23){ h-= 24; d++; } m = numtominutes; } if( d > 0){ return d + " days " + h + " hours " + m +" minutes "; }else{ return h+":"+m; }
this code given me nice user here on stack overflow. since new programming, javascript have no idea put variable. have var howlong = (0,1 * amount + 0,2 * time)
want convert hours , minutes code above, don't know how tell function it's var howlong
.
can me out?
may this?
var ndays = math.floor(sec/86400); var nhours = math.floor((sec%86400)/3600); var nminutes = math.floor(((sec%86400)%3600)/60); var nseconds = ((sec%86400)%3600)%60; return ndays + " days " + nhours + " hours " + nminutes + " minutes " + nseconds + " seconds";
Comments
Post a Comment