ghqwerty Posted October 27, 2008 Share Posted October 27, 2008 i am soo confused. i am trying to devise a formula to work out how many minutes are in a lengthof time and store that in a variable and then store the leftover as a variable eg $timetowait = 621; //work out how many minutes (lots of 60) are in it in this case 10 $minutes = 10; //work out leftover $seconds = 21; however i cant think of a way to do this Link to comment https://forums.phpfreaks.com/topic/130269-solved-time/ Share on other sites More sharing options...
trq Posted October 27, 2008 Share Posted October 27, 2008 Devide your total by 60. Link to comment https://forums.phpfreaks.com/topic/130269-solved-time/#findComment-675551 Share on other sites More sharing options...
trq Posted October 27, 2008 Share Posted October 27, 2008 Sorry, I didn't read your entire question. You'll need to devide the total by 60 then mutiply the decimal x 60 to get the remaining seconds. Link to comment https://forums.phpfreaks.com/topic/130269-solved-time/#findComment-675553 Share on other sites More sharing options...
ghqwerty Posted October 27, 2008 Author Share Posted October 27, 2008 but how would i select that decimal to * it by 60 ? so like 621/ 60 = 10.35. how would i select the .35 to * it by 60 which would = 21 Link to comment https://forums.phpfreaks.com/topic/130269-solved-time/#findComment-675558 Share on other sites More sharing options...
ghqwerty Posted October 27, 2008 Author Share Posted October 27, 2008 i used floor() to get the number then took that away from the total to leave me with the decimal to * by 60 thanks Link to comment https://forums.phpfreaks.com/topic/130269-solved-time/#findComment-675764 Share on other sites More sharing options...
Barand Posted October 27, 2008 Share Posted October 27, 2008 <?php $timetowait = 621; $mins = (int)($timetowait/60); $secs = $timetowait % 60; echo "$mins:$secs"; ?> Link to comment https://forums.phpfreaks.com/topic/130269-solved-time/#findComment-676124 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.