0

Possible Duplicates:
What can use for DateTime::diff() for PHP 5.2 ?
Getting the difference between two time/dates using php?

Hi,

i have use this function: DateTime::diff()

but this function work only with 5.3.

Maybe somebody have the same function who work with 5.2?

Thanks

Community
  • 1
  • 1
lolalola
  • 3,773
  • 20
  • 60
  • 96
  • 1
    Have you searched here? http://stackoverflow.com/search?q=php+time+difference – Felix Kling Nov 10 '10 at 10:54
  • 1
    This was asked just 2 weeks ago: [What can use for DateTime::diff() for PHP 5.2 ?](http://stackoverflow.com/questions/4033224/what-can-use-for-datetimediff-for-php-5-2) – BoltClock Nov 10 '10 at 10:55
  • @Felix that one is asking for timestamp based comparison, not `DateTime` – Pekka Nov 10 '10 at 11:04
  • @Pekka: Mmh maybe I don't understand, but what is the difference? `DateTime::diff()` is to get the difference between two dates right? What is the difference to the question I linked to? (or is it that the search should be `php+date+difference`?) – Felix Kling Nov 10 '10 at 16:00
  • @Felix the `DateTime` class has a different storage format from UNIX timestamps. `DateTime` dates can go beyond 1970 and 2038, so timestamp based comparison may break – Pekka Nov 10 '10 at 17:09

1 Answers1

1

The user contributed notes to date_diff() (always look there first, there's usually something there) offer an alternative.

I've not used it myself but it looks okay. It uses timestamps for comparison, so you won't be able to handle dates < 1970 or > 2038 with it.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088