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
2010-02-15 01:28:18
ok, tnx, i thought there might be helpers for this
flufferok
2010-02-16 08:01:12
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
2010-02-16 10:38:28