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"; } Link to comment https://forums.phpfreaks.com/topic/209013-number-formating-for-time/ 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 Link to comment https://forums.phpfreaks.com/topic/209013-number-formating-for-time/#findComment-1091718 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); Link to comment https://forums.phpfreaks.com/topic/209013-number-formating-for-time/#findComment-1092010 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.