Q:

Days between date do not working...

Hello I wrote php code for calculate days between two dates. Can you show me where I make mistake?
$today = date("Y-m-d");
$date = "2015-03-08";
$temp = date_create($date);
$datediff = $today - $temp;
$days = floor($datediff/(60*60*24));

A:

You can use phps DateTime Object:
$today = new DateTime(); // Passing no argument defaults to today
$newYear= new DateTime('2016-01-01');
$interval = $today->diff($newYear);
$diff = $interval->format('%a');

echo $diff;

Output
5

If you want to have a signed number then use this
$diff = $interval->format('%R%a');

Output
-5

So you know $newYear was 5 days before $today.

