views:

311

answers:

2

Hi, i want to make stackoverflow timestamps(X minutes ago, etc). How i can make it using zend_date? I found http://stackoverflow.com/questions/1639892/how-to-calculate-time-passed-with-php-or-zend-date this realisation, but it uses other library. Are there any different ways?

A: 

You can subtract timestamps of two dates to find difference between them in seconds and then use division and modulo to represent it as minutes, days etc.

Aivean
ok, tnx, i thought there might be helpers for this
flufferok
A: 

How about Zend_Date::subDate()?

$d1 = new Zend_Date();
$d2 = new Zend_Date($old_date);
$diff = $d1->subDate($d2);

After you've got the difference, you can check out one of these helpers:

chelmertz