开发者

zend_date relative time

i want to make stackoverflow timestamps(X minutes ago, etc). How i can make it using zend_d开发者_如何学Cate? I found How to calculate time passed with PHP or Zend_Date? this realisation, but it uses other library. Are there any different ways?


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:

  • Relative time view helper
  • Zend_View_Helper_Relativetime


Even if you don't want the whole Zym framework, you could still add their TimeSince view helper to your own application.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜