/** * @see CakeTime::timeAgoInWords() * * ## Addition options * * - `element` - The element to wrap the formatted time in. * Has a few additional options: * - `tag` - The tag to use, defaults to 'span'. * - `class` - The classname to use, defaults to `time-ago-in-words`. * - `title` - Defaults to the $dateTime input. * * @param integer|string|DateTime $dateTime UNIX timestamp, strtotime() valid string or DateTime object * @param array $options Default format if timestamp is used in $dateString * @return string Relative time string. * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/time.html#formatting */ public function timeAgoInWords($dateTime, $options = array()) { $element = null; if (is_array($options) && !empty($options['element'])) { $element = array( 'tag' => 'span', 'class' => 'time-ago-in-words', 'title' => $dateTime ); if (is_array($options['element'])) { $element = array_merge($element, $options['element']); } else { $element['tag'] = $options['element']; } unset($options['element']); } $relativeDate = $this->_engine->timeAgoInWords($dateTime, $options); if ($element) { $relativeDate = sprintf( '<%s%s>%s</%s>', $element['tag'], $this->_parseAttributes($element, array('tag')), $relativeDate, $element['tag'] ); } return $relativeDate; }