Jump to content

Problem in Time


newphpbees

Recommended Posts

Hi..

 

 

I got an issue in getting the total time.

 

I have this code to get the sum of total time:

 

$result = mysql_query("INSERT INTO payroll.casual_hours(EMP_NO, Hours) SELECT EMP_NO, sec_to_time(SUM(time_to_sec(Rendered))) FROM payroll.casual_att WHERE DATE_FORMAT(LOGOUT, '%W') IN ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') GROUP BY EMP_NO") or die(mysql_error()); 

 

Rendered:

09:00:00

09:00:00

09:00:00

08:00:00

08:00:00

07:48:00

 

and the result of this is 50:48

 

but I need result is 50:80

 

the minutes is divided to 60

 

Is there any way to get the 50:80 result.

 

 

Thank you so much..

Link to comment
https://forums.phpfreaks.com/topic/256236-problem-in-time/
Share on other sites

In payroll minutes was divided into 60.

 

i tried this:

  $TotHours = substr($Hours, 0, 3);
  $Minutes = substr($Hours,4,2);
  $Minutes = substr($Hours,3,2);
  $Minutes_Convert = ($Minutes / 60); 
  $Minutes_Convert = number_format($Minutes_Convert, 2, '.', '');
  $Hours = $TotHours + $Minutes_Convert;

but i encountered problem when TotHours  = 100 the substr was not capable.

Link to comment
https://forums.phpfreaks.com/topic/256236-problem-in-time/#findComment-1313598
Share on other sites

If you're going for percentage of time, rather than actual minutes, you might need to convert your hours into minutes, then add those to the remainer minutes, then divide it all by 60.

 

i.e., 04h30m = 240 + 30 = 270 / 60 = 4.5

 

And it would be a "." not a ":" when you're displaying the hours.

Link to comment
https://forums.phpfreaks.com/topic/256236-problem-in-time/#findComment-1313607
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.