Question: I see there are other posts on this question in other languages, but I can't find one for PHP. I'm not looking for the difference between two date times, but rather how many days different. For example:

`2011-08-06 14:05:28`

and

`2011-08-07 08:46:28`

are less then one day apart, but I want a function that will tell me they are on days that are one day apart, i.e. will return a value of `1` for these two dates, and return a value of `2` for the following dates, for example:

`2011-08-06 23:05:28`

and

`2011-08-08 01:46:28`

Really, I'm guessing it must be easy, but I've not worked much with dates before.

Oh, and one more constraint, I need something compatible with PHP 5.2, so can't use `DateTime::diff`.

EDIT: changed to clarify that I do really need a numeric return value, sorry :)

Answer: 
if i interpret the question correctly, you need [GregorianToJD](http://php.net/manual/en/function.gregoriantojd.php) or mysql [to\_days](http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_to-days)

Both functions return a [julian day](http://en.wikipedia.org/wiki/Julian_day) for a specific date, which is basically the number of days since "day 0".
1. Convert the dates into timestamps. How this is done depends on the format of the input data.
2. Format the timestamps using PHP's [`date`](http://php.net/manual/en/function.date.php) function (`Ymd` seems like a suitable `$format`).
3. Compare the resulting strings for equality.

If you need the actual difference in days, call `date` separately using `Y`, `m` and `d` as formats, construct timestamps from the result (using [`mktime`](http://www.php.net/manual/en/function.mktime.php)) and divide the difference between the timestamps by 86400 (the number of seconds per day).