Jump to content

if number is a negative number, add 24


flemingmike

Recommended Posts

hello,  i have a start time and an end time (no dates).  the following works great, except for when the start time is at night, and the end time is in the morning.  im thinking if i can do an if the number is negative, add 24, that it will resolve my issue.

 

any ideas?

 

$tbilled = $tfinish - $tstart;

Link to comment
https://forums.phpfreaks.com/topic/214593-if-number-is-a-negative-number-add-24/
Share on other sites

perfect.  one other thing i just noticed.  when it does the subtraction, it is only subtracting the hour, not the minutes.  here is what i have, any ideas?

 

the format for my time is 00:00:00

 

$tbilled = $tfinish - $tstart - $tlunch;
  
  if($tbilled < 0)
{
    $tbilled1 = $tbilled + 24;
} else {
    $tbilled1=$tbilled;
  }

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.