3
I have a problem with the sum of dates.
I have several events that are registered in the bank with initial date and final date, I need to know the time interval between these events and add up these intervals to know the total time that lasted these events. To calculate the time difference of an event I use the method diff
class DateTime
, but I can’t add up those intervals. Someone can help me?
Follow the code below:
$intervalo1 = date_diff($objDataInicio1, $objDataFim1);
$intervalo2 = date_diff($objDataInicio2, $objDataFim2);
$somaDosIntervalos = $intervalo1+$intervalo2 ?????
I can even sum up the numbers of days, months and years, but that doesn’t work because the sum value is as integer not as date, so if you have 25 days in the first interval and 20 days in the second the result of the calculation will be 45 days, not 1 month and 15 days.
Vanderson, this I had done, but I want to add up the diff of several different dates
– Celson Rodrigues