Q:

Round down date and find different's

I trying to find a script which will round down a date to the nearest day and tell me how many days different's between them.  Want it to return like this:
0 = today
1 = yesterday
2 = 2days ago...
you get the idea
This is what ive got so far.  
$delta = ((strtotime(date('d/m/y', time())) - strtotime(date('d/m/y', $time))))/86400;

But this returns like this:
0 = for today
30 = yesterday
61 = for the day before....
It driving me mad..... 

A:

Try using the format date('Y-m-d', $dateStr) (notice the order of year, month, day), as this is the prefered format for PHP date operations and one of the ISO8601 notations.
Also, there's a problem in the code you posted. No need for this: date('d/m/y', $time), as $time I presume is a string. It actually throws a Notice. See working code below:
$timeStr = '2012-03-06';

$delta = abs((strtotime(date('Y-m-d', time())) - strtotime($timeStr)))/(60*60*24);

echo $delta;

Should output 1, as the current date is 2012-03-07.

