Jump to content

Recommended Posts

Hi All,

 

I'm trying to find a way to calculate the total time in seconds of when 3 different times intersect each other.

 

e.g.

 

Start Time End Time Duration 2013-10-08 08:29:52 2013-10-08 08:32:46 00:02:54 2013-10-08 08:31:57 2013-10-08 08:32:46 00:00:49 2013-10-08 08:32:06 2013-10-08 08:36:28 00:04:22

 

From my calculation it will 85 seconds of overlapping time.

 

Can anyone assist?

Link to comment
https://forums.phpfreaks.com/topic/283689-calculating-the-subset-of-time/
Share on other sites

Start Time                      End Time                       Duration

2013-10-08 08:29:52      2013-10-08 08:32:46     00:02:54

2013-10-08 08:31:57      2013-10-08 08:32:46     00:00:49

2013-10-08 08:32:06      2013-10-08 08:36:28     00:04:22

 

 

Hopefully the above displays better.

Hi jazzman1,

 

Thanks for your response.

 

I was more looking at the subset or intersection of the the three rows where the End Time of all the rows do not exceed the End Time of the first row.

 

Actually my initial calculation of 85 seconds is incorrect. I believe it should be 40 seconds.

 

Here is my logic:-

 

From the first row the duration is 00:02:54 or 174 seconds.

The second row the Start and End time falls within the first Start and End and the duration is 49 seconds and is the total subset time used at this time.

The third row starts within the second row but ends after the second row so the duration will be a difference of 2013-10-08 08:32:06  and  2013-10-08 08:32:46 which is 40 seconds.

 

I hope I am a bit clearer.

Perhaps...

 

new_start_time would be LATEST start time of the three

new_end_time would be EARlIEST end time of the three

those two would be the common intersection/duration of the three

(would apply to more or less time sequences)

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • 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.