flufferok
flufferok

Reputation: 1

zend_date relative time

i want to make stackoverflow timestamps(X minutes ago, etc). How i can make it using zend_date? I found How to calculate time passed with PHP or Zend_Date? this realisation, but it uses other library. Are there any different ways?

Upvotes: 0

Views: 1522

Answers (3)

cmbuckley
cmbuckley

Reputation: 42547

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

Upvotes: 1

chelmertz
chelmertz

Reputation: 20601

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:

Upvotes: 2

user273181
user273181

Reputation:

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.

Upvotes: 0

Related Questions