Answer the question
In order to leave comments, you need to log in
Why does date_diff return the wrong number?
I consider the difference between two dates, I can not understand why it gives out such a number.
$format = 'd.m.Y';
$val1 = "05.11.2019";
$val2 = "02.02.2020";
$val1 = date_create_from_format($format, $val1);
$val2 = date_create_from_format($format, $val2);
$countOfDays = date_diff($val2 , $val1) -> format("%d");
Answer the question
In order to leave comments, you need to log in
everything is correct, %d is the number of days within a month if
you want to see the total number of days - use %a
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question