Consider these two dates 2017/4/14, 2017/6/3
Using date_diff in php gives me this
object(DateInterval)[6]
public 'y' => int 0
public 'm' => int 1
public 'd' => int 20
public 'h' => int 0
public 'i' => int 0
public 's' => int 0
public 'weekday' => int 0
public 'weekday_behavior' => int 0
public 'first_last_day_of' => int 0
public 'invert' => int 0
public 'days' => int 50
public 'special_type' => int 0
public 'special_amount' => int 0
public 'have_weekday_relative' => int 0
public 'have_special_relative' => int 0
I have a task of creating a replicate of this function (as a assignment). But when I run these dates through my algorithm I get
object(stdClass)[4]
public 'years' => int 0
public 'months' => int 1
public 'days' => int 19
public 'total_days' => int 50
public 'invert' => int 0
And when I calculate the number of days by hand (manually) I still see this as 19 extra days. I am not looking for the assignment solution. But maybe some algorithm or maybe the date_diff function has some bugs I am not aware of?
For 200+ test cases my algorithm works, for 7 others it does not and it's always a day difference between my solution and php solution.