Can someone tell me why this code prints 12 ?
$_POST['sdate']
in this example is: 2018-10-31
$_POST['date']
in this example is: 2019-07-13
$startDate = DateTime::createFromFormat('Y-m-d', $_POST['sdate']);
$endDate = DateTime::createFromFormat('Y-m-d', $_POST['date']);
$dif2 = date_diff($startDate, $endDate);
$diff2 = $dif2->format('%d');
echo $diff2;
This calculates me badly with almost any date, but I have put that example because it is very clear that it is not correct (as far as I know).
Thank you very much.