Hi,
There is a form on my site that requires that the user types in the start time and end time of down time. If this sounds confusing, check it out: This system logs the downtime for aircraft at my company, and the user must be able to type in the time the aircraft became out of service, as well as the time the aircraft became back in service. I need the PHP to calculate the difference and insert that number (in hours) into my DB, but I'm not sure how to do this since time goes doesn't work in intervals of 100, but 60. Is there some sort of built-in fuction to deal with this? What can I do to resolve this problem?
Thanks,
- Jeff
subtracting times
Moderator: General Moderators
-
ibanez270dx
- Forum Commoner
- Posts: 74
- Joined: Thu Jul 27, 2006 12:06 pm
- Location: Everywhere, California
-
ibanez270dx
- Forum Commoner
- Posts: 74
- Joined: Thu Jul 27, 2006 12:06 pm
- Location: Everywhere, California
-
ibanez270dx
- Forum Commoner
- Posts: 74
- Joined: Thu Jul 27, 2006 12:06 pm
- Location: Everywhere, California
all I need is the hours - from a start time to finish time. Usually the maintenance is completed in one day, thus I wouldn't have to deal with the days. I would like it to count days if possible, just in case that scenario ever did come about.
I was thinking the times would be entered via a regular old text input box.
I was thinking the times would be entered via a regular old text input box.
-
ibanez270dx
- Forum Commoner
- Posts: 74
- Joined: Thu Jul 27, 2006 12:06 pm
- Location: Everywhere, California
I ended up not using the day thing, but I put the times in Unix Timestamps using this method:
however, my output is in decimal form - EX:, I put in 08:00 to 13:45 and got 5.75 for the difference. Is there any way to put this into a time standard format? Such as 5:45 or 5hrs and 45mins or something?
Thanks again,
- Jeff
Code: Select all
$date_a = strtotime($dwntime_hrs1);
$date_b = strtotime($dwntime_hrs2);
$dthrs = ($date_b-$date_a)/3600;Thanks again,
- Jeff
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
viewtopic.php?t=52658 may be of interest.