AirBoss36 Posted July 27, 2010 Share Posted July 27, 2010 Hi Folks, I understand the basic math to accomplish what I want, at least I think I do I would like to confirm my logic and I need help with the final output format. I am coding a simple browser based, resource type of game. The gamer will select a certain item to produce another item and it will take x time to do it. Here is the basics of what I want, minus the coding to make it look pretty. How do I format $y to show HHH:MM:SS? $complete = time() + $x; // To show how much time is remaining until completion or complete $y = $complete - time(); if $y > 0 { echo $y; } else { echo "complete"; } Quote Link to comment Share on other sites More sharing options...
aleX_hill Posted July 27, 2010 Share Posted July 27, 2010 take a look at http://php.net/manual/en/function.date.php echo date("h:i:s",$y); should do it Quote Link to comment Share on other sites More sharing options...
AirBoss36 Posted July 28, 2010 Author Share Posted July 28, 2010 I tried that format but it didn't work as I wanted. It seemed to add the time to the current time. I did a quick coding to test, using a value of 10,800 for x to show 3 hours remaining, but it added 3 hours to the current time of 07:00 to echo a value of 10:00:00 Any other ideas? Perhaps I coded wrong? Here is what I used: $x = 10855; echo $x; echo "<br>"; echo date("h:i:s",$x); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.