I have a problem with the sum of dates.
I have several events that are registered in the bank with start date and end date, I need to know the time interval between these events and add these intervals to know the total time that these events lasted. To calculate the time difference of an event I use the diff
method of class DateTime
, but I can not add these intervals. Can anyone help me?
The following is the code below:
$intervalo1 = date_diff($objDataInicio1, $objDataFim1);
$intervalo2 = date_diff($objDataInicio2, $objDataFim2);
$somaDosIntervalos = $intervalo1+$intervalo2 ?????
I can even sum the numbers of days, months, and years, but that does not work because the sum added is as an integer not a date, so if you have 25 days in the first interval and 20 days in the second the result of calculation will be 45 days, not 1 month and 15 days.