Hello, I need to calculate the average time between some DateInterval.
Actually, I have some Dateinterval:
for ($i = 0 ; $i < count($startDate) ; $i++) { $diffTable[] = date_diff($finishDate[$i], $startDate[$i]); echo $diffTable[$i]->format("%Y-%M-%d %H:%i:%s"); }
Here is the result:
00-00-0 00:13:17 00-00-0 00:7:47 00-00-0 00:7:14 00-00-0 00:10:39
I need to calculate the average time between these intervals. Here it is only minutes and seconds, but it can be a month or a year.
I cannot find a good way to easily figure it out. I can simply add each dateInterval with this conversion:
sec + 60xmin + 3600xHour ...
And they play with the module (%).
But I hope there is another way?
source share