date_diff()
returns a DateInterval
object which you need to call format()
on to get the actual value from it. In this case you will use %d
to get the number of days.
//get days
$a = date_create($arrive);
$d = date_create($leave);
$diff = date_diff($d,$a);
echo '<input type="hidden" id="days" value="'.$diff->format("%d").'"/>';
Just keep in mind this will only go up to 31. From there you will need to use %m
with %d
to also display months.