Jasdeep Khalsa
Jasdeep Khalsa

Reputation: 6929

Date and time difference function for PHP 5.1

PHP 5.3.0+ has a DateTime::diff function: http://docs.php.net/datetime.diff

Unfortunately I am currently using the PHP 5.1 branch with no possibility to upgrade. So what is the best way to work out a date-time difference?

For example the time difference between 22-01-2013 17:00 and 23-01-2013 13:00.

I am not really worried about the output format as such.

Upvotes: 1

Views: 1706

Answers (2)

Fabian Blechschmidt
Fabian Blechschmidt

Reputation: 4141

Zend framework doesn't run on PHP 5.1 ... the last version which supports PHP 5.1 was Zend Framework 1.6 (http://framework.zend.com/manual/1.6/en/requirements.version.html) but you shouldn't use it.

If you want to have a nice interface, you can use Zend_Date.

http://framework.zend.com/manual/1.12/de/zend.date.overview.html#id.date.basic.operations

If you want it fast and with php core, just use strtotime as @dipesh-parmar suggested

Upvotes: 1

Dipesh Parmar
Dipesh Parmar

Reputation: 27364

All you need to know is strtotime php function.

Upvotes: 1

Related Questions