I want to get the number of days between the two dates.
// DD-MM-YYYY
$date[0] = "01-03-2023";
$date[1] = "30-03-2023";
echo date_diff(date_create($date[0]),date_create($date[1]))->d + 1;
The program above returns 2
, instead of the right number of days.
2
Answers
Try with this code :
or
Result :
You should call
date_diff()->days
which returns the number of days between the 2 dates.Please change:
To this: