PHP & Math
July 28th, 2013
I’m not a genius in math or PHP, so I thought I should try my luck here
I have a script which outputs the number of seconds you have to wait until you can do a new crime (it will be a mafia game ). The number is 240 after you finished a crime. I would like to show the user “You have to wait x minutes and y seconds” instead of “You have to wait xyz seconds”.
Minutes aren’t hard to be calculated (using floor() and dividing seconds left by 60). I have problems with seconds, any idea how should I do that?
Thanks in advice!
floor(xyzseconds/60) gives you the min
60*(xyzseconds%60) gives you the seconds.
more here: http://php.net/manual/en/language.operators.arithmetic.php
thanks!