gusaps Posted October 8, 2008 Share Posted October 8, 2008 Hi... I'm programing something like this... (I'm really a beginner on PHP) http://www.airrouting.com/content/TimeDistanceForm.aspx I have already most of the code on my PHP... but when come to the simplest I cannot find the answer... after the time duration: $duration = $distNM / 400; // distance in nautical miles / per 400 knots average speed I need to show the time in a nice way... like HH:MM, and I cannot find the way to convert the decimals from the formula to time... I guess must be an easy way on the date & time functions but i cannot find it... I need some help on this... Thanks in advance... Quote Link to comment Share on other sites More sharing options...
Orio Posted October 8, 2008 Share Posted October 8, 2008 I cannot find the way to convert the decimals from the formula to time From that I can't really understand in what format your time currently is. An example would be great. Orio. Quote Link to comment Share on other sites More sharing options...
gusaps Posted October 8, 2008 Author Share Posted October 8, 2008 hi Orio, thanks for your interest.... I see what u mean... The result I get is in hours... because 400 knots per hour is how i measure the speed on the equation... is about 740km/h or 460miles/h Is that what you need? thanks Quote Link to comment Share on other sites More sharing options...
Orio Posted October 8, 2008 Share Posted October 8, 2008 So what you're getting is something like "5.8641 Hours" and you want to convert it into "5 Hours + X minutes" ? This should do: <?php $num_hours = 5.8641; //some float $hours = floor($num_hours); $mins = round(($num_hours - $hours) * 60); echo $hours." Hours and ".$mins." minutes"; ?> Orio. Quote Link to comment Share on other sites More sharing options...
gusaps Posted October 8, 2008 Author Share Posted October 8, 2008 OK! iT WORKS... thanks a lot Orio! c'u 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.