Jump to content

Recommended Posts

Posted

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

Posted

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

Guest lorathon
Posted

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

Guest lorathon
Posted

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.

  • Administrators
Posted

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

Posted

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'];

Posted

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 ;)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...