Hi,
I have run into a problem in a program I'm writing for my client... Heres the story:
I am developing a system that logs the downtime of aircraft due to many different reasons. One of them is maintenance. The maintenance work is based on a 24 hour day. Thus, the log is based on a 24 hour time scale where a user can log a downtime (ex: 05:00 to 14:30). However, the hours of operation for these aircraft is based on an 18 hour day (05:00 to 23:00). What I need to do is to be able to take a 24hr day maintenance log and convert it to an 18hr day to log the downtimes in operation.
Here is an example: Let's say that the aircraft is down for maintenance between the hours of 01:00 and 08:00. I need to convert this 24 hour scale to an 18 hour scale. In actuallity, I need to take the overlapping hours and store them in a variable. The hours of operation are 05:00 to 23:00, thus with the example of 01:00 to 08:00, I would count 05:00 to 08:00. How would I do that?
Its kinda confusing, I know, but any help is greatly appreciated!!!!
Thank you!
- Jeff
Manipulating Times
Moderator: General Moderators
-
ibanez270dx
- Forum Commoner
- Posts: 74
- Joined: Thu Jul 27, 2006 12:06 pm
- Location: Everywhere, California
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Some rough code
Code: Select all
$timeDiff = $timeEnd - $timeStart;
$eighteenHours = 18 * 3600;
$days = floor($timeDiff / $eighteenHours);
$remainder = $timeDiff % $eighteenHours;-
ibanez270dx
- Forum Commoner
- Posts: 74
- Joined: Thu Jul 27, 2006 12:06 pm
- Location: Everywhere, California
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
$timeEnd and $timeStart are unix timestamps of when the work ended and started, respectively. $eighteenHours is, well eighteen hours (in seconds, the unit of measure in unix timestamps.) $days is the number of eighteen hour days the work took. $remainder is any remaining time into the $days + 1 day.
-
ibanez270dx
- Forum Commoner
- Posts: 74
- Joined: Thu Jul 27, 2006 12:06 pm
- Location: Everywhere, California
- MarK (CZ)
- Forum Contributor
- Posts: 239
- Joined: Tue Apr 13, 2004 12:51 am
- Location: Prague (CZ) / Vienna (A)
- Contact:
Code: Select all
mktime(5, 0, 0);