当前位置: 首页>>代码示例>>PHP>>正文


PHP TimeHelper::timeAgoInWords方法代码示例

本文整理汇总了PHP中TimeHelper::timeAgoInWords方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeHelper::timeAgoInWords方法的具体用法?PHP TimeHelper::timeAgoInWords怎么用?PHP TimeHelper::timeAgoInWords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TimeHelper的用法示例。


在下文中一共展示了TimeHelper::timeAgoInWords方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: timeAgoInWords

 public function timeAgoInWords($dateTime, $options = array())
 {
     if (!isset($this->Asset) || !$this->settings['relativeTime']['enabled'] || isset($options['useCore'])) {
         unset($options['useCore']);
         return parent::timeAgoInWords($dateTime, $options);
     }
     if (!$this->_jsAdded) {
         if ($this->settings['relativeTime']['jsPacket'] !== false) {
             $this->Asset->js(array('jquery.timeago', 'jquery.mi.relativeTime'), $this->settings['relativeTime']['jsPacket']);
         }
         $this->_jsAdded = true;
     }
     $date = date('Y-m-d H:i:s O', $this->fromString($dateTime));
     return String::insert($this->settings['relativeTime']['tag'], array_merge($options, compact('date')));
 }
开发者ID:razzman,项目名称:mi,代码行数:15,代码来源:MiTimeHelper.php

示例2: testTimeAgoInWords

 /**
  * Test element wrapping in timeAgoInWords
  *
  * @return void
  */
 public function testTimeAgoInWords()
 {
     $Time = new TimeHelper($this->View);
     $timestamp = strtotime('+8 years, +4 months +2 weeks +3 days');
     $result = $Time->timeAgoInWords($timestamp, array('end' => '1 years', 'element' => 'span'));
     $expected = array('span' => array('title' => $timestamp, 'class' => 'time-ago-in-words'), 'on ' . date('j/n/y', $timestamp), '/span');
     $this->assertTags($result, $expected);
     $result = $Time->timeAgoInWords($timestamp, array('end' => '1 years', 'element' => array('title' => 'testing', 'rel' => 'test')));
     $expected = array('span' => array('title' => 'testing', 'class' => 'time-ago-in-words', 'rel' => 'test'), 'on ' . date('j/n/y', $timestamp), '/span');
     $this->assertTags($result, $expected);
     $timestamp = strtotime('+2 weeks');
     $result = $Time->timeAgoInWords($timestamp, array('end' => '1 years', 'element' => 'div'));
     $expected = array('div' => array('title' => $timestamp, 'class' => 'time-ago-in-words'), '2 weeks', '/div');
     $this->assertTags($result, $expected);
 }
开发者ID:Oswald-Dsa,项目名称:cakephp-ex,代码行数:20,代码来源:TimeHelperTest.php

示例3: cakeAgo

/**
 * Wrapper to Time->timeAgoInWords()
 * @param $var
 * @return mixed
 */
function cakeAgo($var)
{
    $time = new TimeHelper();
    return $time->timeAgoInWords($var);
}
开发者ID:alanrodas,项目名称:TwigView,代码行数:10,代码来源:Twig_Extension_Ago.php

示例4: timeAgoInWords

 /**
  * Returns either a relative date or a formatted date depending
  * on the difference between the current time and given datetime.
  * $datetime should be in a <i>strtotime</i> - parsable format, like MySQL's datetime datatype.
  *
  * ### Options:
  *
  * - `format` => a fall back format if the relative time is longer than the duration specified by end
  * - `end` => The end of relative time telling
  * - `userOffset` => Users offset from GMT (in hours)
  *
  * Relative dates look something like this:
  *	3 weeks, 4 days ago
  *	15 seconds ago
  *
  * Default date formatting is d/m/yy e.g: on 18/2/09
  *
  * The returned string includes 'ago' or 'on' and assumes you'll properly add a word
  * like 'Posted ' before the function output.
  *
  * @param string $dateString Datetime string or Unix timestamp
  * @param array $options Default format if timestamp is used in $dateString
  * @return string Relative time string.
  * @access public
  * @link http://book.cakephp.org/view/1471/Formatting
  */
 function timeAgoInWords($dateTime, $options = array())
 {
     return parent::timeAgoInWords($dateTime, $this->__userOffset($dateTime, $options));
 }
开发者ID:nani8124,项目名称:infinitas,代码行数:30,代码来源:InfiniTimeHelper.php


注:本文中的TimeHelper::timeAgoInWords方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。