View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFPROP:Proposal Zone Template}


[Geoffrey Tran|] ([Google+|])


1.0 - 1 January 2008: Initial Draft.

This helper calculates the time passed from timestamps to generate a formatted string like "5 days and 4 hours". Applications of this helper are generally seen in "Created 2 weeks ago" or "Last modified 5 minutes ago" type lines.

Units supported are years, months, weeks, days, minutes, seconds. String format is the largest possible unit and if possible the unit below it. If a 1 year and 2 weeks have passed then "1 year" is the output; however, if 1 year, 2 months and 5 days have passed then "1 year and 2 months" is returned. If less than a second have passed then "less than a second" is returned.

Output is automatically translated if possible using Zend_View_Helper_Translate. The translation format is '%d months'. An already completed gettext pot file is located on Zym's demo in the data locale folder.

* [Zym Project's TimeSince|]
* [Zym Project's TimeSince gettext POT|]

* This component *will* extend Zend_View_Helper_Abstract
* This component *will* allow the use of translation
* This component *will* format a date using a timestamp

* Zend_View_Helper_Abstract
* Zend_View_Helper_Translate

Calculates time passed since a specified time.

* Milestone 1: [DONE] Proposal creation
* Milestone 2: [DONE] Working Code, Documentation, Tests
* Milestone 3: Working prototype checked into the incubator.
* Milestone 4: Unit tests exist, work, and are checked into SVN.
* Milestone 5: Initial documentation exists.

* Zend_View_Helper_TimeSince

<!-- Simple -->
Last updated <?= $this->timeSince($timestamp); ?> ago

<!-- Time since a specified timestamp -->
<?= $this->timeSince($timestamp, strtotime('+1 day')); ?>

class Zend_View_Helper_TimeSince
      public function timeSince($timestamp, $time = null)