faraz Posted July 7, 2010 Report Share Posted July 7, 2010 Hello I want change time format for Total Flight Hours in my website , 25.49 -> 25:49:00 (HH:MM:SS) I try to sum flighttime_stamp in pireps table : $params = array( 'table' => TABLE_PREFIX.'pireps', 'fields' => 'SUM(`flighttime_stamp`) AS `total`', 'where' => array('accepted' => PIREP_ACCEPTED), ); $sql = DB::build_select($params); $results = DB::get_results($sql); echo $total = $results[0]->total; That code shown Total Flight Hours 20:30:12 (HH:MM:SS) but my VA Total Flight Hours is 25.49 . I don't understand why !! Tnx Quote Link to comment Share on other sites More sharing options...
Jeff Posted July 8, 2010 Report Share Posted July 8, 2010 The system can't calculate time in time format. All it can do is calculate it in numbers. If your flight time was 1:30 for a flight, the system will calculate it as 1.50 or just 1.5 Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted July 8, 2010 Report Share Posted July 8, 2010 Faraz, Try this SUM(TIME_TO_SEC(flighttime_stamp)) as hours I use this to get total minutes and then convert for my own format SUM(TIME_TO_SEC(flighttime_stamp)/60) as minutes Quote Link to comment Share on other sites More sharing options...
Jeff Posted July 8, 2010 Report Share Posted July 8, 2010 Cool. Thanks Jeff, I will try that as well Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted July 8, 2010 Report Share Posted July 8, 2010 Not a problem. Not sure how it will work in the first instance. But I know that my code at the bottom to get the total minutes works. Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted July 8, 2010 Administrators Report Share Posted July 8, 2010 The system can't calculate time in time format. All it can do is calculate it in numbers. If your flight time was 1:30 for a flight, the system will calculate it as 1.50 or just 1.5 Actually it will be in hours:minutes. It was an issue a while ago but it should be all good now Quote Link to comment Share on other sites More sharing options...
faraz Posted July 9, 2010 Author Report Share Posted July 9, 2010 HI I try to use below code in php , but no data shown, but in SQL shown 41:48:22 $sql="SELECT SEC_TO_TIME(SUM( TIME_TO_SEC( flighttime_stamp ) ) )AS total_time FROM phpvms_pireps"; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['SEC_TO_TIME(SUM( TIME_TO_SEC( flighttime_stamp ) ) )AS total_time']; Quote Link to comment Share on other sites More sharing options...
piuozorio Posted July 9, 2010 Report Share Posted July 9, 2010 HI I try to use below code in php , but no data shown, but in SQL shown 41:48:22 $sql="SELECT SEC_TO_TIME(SUM( TIME_TO_SEC( flighttime_stamp ) ) )AS total_time FROM phpvms_pireps"; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo $row['SEC_TO_TIME(SUM( TIME_TO_SEC( flighttime_stamp ) ) )AS total_time']; Hello, I use a similar code in my website and using SEC_TO_TIME(SUM( TIME_TO_SEC the database will return the value but with a limit of 859:...... hours. About your error, try changing to echo $row['total_time']; Hope it help and sorry my english 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.