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


PHP Time::ago方法代码示例

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


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

示例1: cache_expire

 /**
  *  Overridden
  */
 function cache_expire()
 {
     $filename = $this->cached_page_filename();
     if (file_exists($filename) && filemtime($filename) < Time::ago(300)) {
         $this->expire_cached_page($_REQUEST);
     }
 }
开发者ID:emeraldion,项目名称:creso,代码行数:10,代码来源:graph_controller.php

示例2: date

 /**
  * Return the timestamp with the user's timezone and his display options.
  * @param integer $timestamp time in seconds
  * @param integer $ago_days  number of days to display x day(s) ago formating
  */
 public static function date($timestamp, $ago_days = 2)
 {
     // Check if $ago_days is null, or if timestamp is more then time - $ago_days.
     if (!$ago_days or $timestamp > time() - Date::DAY * $ago_days) {
         return Time::ago($timestamp);
     }
     $timestamp += Time::$offset * 3600;
     return date(Time::$display, $timestamp);
 }
开发者ID:joffuk,项目名称:modulargaming,代码行数:14,代码来源:time.php

示例3: test_ago

 /**
  *	@fn test_ago
  *	@short Test method for ago.
  */
 public function test_ago()
 {
     $this->assertEquals(time() - 3600, Time::ago("hour"), 'Bad timestamp');
     $this->assertTrue(Time::ago("hour") < time(), 'Bad timestamp');
     $this->assertEquals(time() - 24 * 3600, Time::ago("day"), 'Bad timestamp');
     $this->assertTrue(Time::ago("day") < time(), 'Bad timestamp');
     $this->assertEquals(time() - 7 * 24 * 3600, Time::ago("week"), 'Bad timestamp');
     $this->assertTrue(Time::ago("week") < time(), 'Bad timestamp');
     $this->assertEquals(time() - 30 * 24 * 3600, Time::ago("month"), 'Bad timestamp');
     $this->assertTrue(Time::ago("month") < time(), 'Bad timestamp');
     $this->assertEquals(time(), Time::ago(), 'Bad timestamp');
     $this->assertEquals(time(), Time::ago(), 'Bad timestamp');
 }
开发者ID:emeraldion,项目名称:zelda,代码行数:17,代码来源:time.test.php

示例4: hits_by_host

 /**
  *	@fn hits_by_host
  *	@short Action method that shows the list of hosts that have visited the website.
  */
 public function hits_by_host()
 {
     $conn = Db::get_connection();
     $conn->prepare("SELECT `ip_addr`, `params`, COUNT(*) AS `weight` " . "FROM `visits` " . "WHERE `gate` LIKE '%{1}%' " . "AND `date` >= '{2}' " . "AND (`ip_addr` LIKE '%{3}%' " . "OR `params` LIKE '%Apache'' => ''%{3}%') " . "AND `referrer` LIKE '%{4}%' " . "AND `user_agent` LIKE '%{5}%' " . "GROUP BY CONCAT(`ip_addr`, `user_agent`) " . "HAVING `weight` >= '{6}' AND `weight` <= '{7}' " . "ORDER BY `weight` DESC " . "LIMIT {8}", @$_REQUEST['p'], date("Y-m-d H:i:s", Time::ago(@$_REQUEST['t'])), @$_REQUEST['f'], @$_REQUEST['r'], @$_REQUEST['u'], @$_REQUEST['l'], @$_REQUEST['h'], 9999);
     $conn->exec();
     $this->hosts = array();
     if ($conn->num_rows() > 0) {
         while ($line = $conn->fetch_assoc()) {
             $host = Geoip::by_ip_addr($line['ip_addr'], $line['params']);
             $host->weight = $line['weight'];
             $this->hosts[] = $host;
         }
     }
     Db::close_connection($conn);
 }
开发者ID:emeraldion,项目名称:zelda,代码行数:19,代码来源:kml_controller.php

示例5: attribute_visits

 /**
  *	@fn attribute_visits
  *	@short Action method to attribute a visit to a person.
  *	@details This method is designed to be called with AJAX, and does not render anything.
  *	It assigns a visit object to a person object.
  */
 public function attribute_visits()
 {
     $conn = Db::get_connection();
     $visit_factory = new Visit();
     $visits = $visit_factory->find_all(array('where_clause' => "`date` >= '{$conn->escape(date("Y-m-d H:i:s", Time::ago(@$_REQUEST['t'])))}' " . "AND (`ip_addr` = '{$conn->escape(@$_REQUEST['ip'])}' " . "OR `params` LIKE '%Apache'' => ''{$conn->escape(@$_REQUEST['ip'])}%')"));
     if (count($visits) > 0) {
         foreach ($visits as $visit) {
             $visit->person_id = @$_REQUEST['person_id'];
             $visit->save();
         }
     }
     Db::close_connection($conn);
     $this->render(NULL);
 }
开发者ID:emeraldion,项目名称:zelda,代码行数:20,代码来源:meta_controller.php

示例6: yiiVersions

 /**
  * @return array
  */
 public static function yiiVersions()
 {
     $_versions = array();
     $p = VENDOR_PATH . DS . 'yii';
     $d = dir($p);
     while (false !== ($entry = $d->read())) {
         if (substr($entry, 0, 4) == 'yii-') {
             $time = filemtime($p . DS . $entry);
             $_versions[$time] = array('entry' => $entry, 'display' => $entry . ' -- ' . date(self::item('dateTimeFormat'), $time) . ' -- (' . Time::ago($time) . ')');
         }
     }
     $d->close();
     krsort($_versions);
     $versions = array();
     foreach ($_versions as $version) {
         $versions[$version['entry']] = $version['display'];
     }
     return $versions;
 }
开发者ID:cornernote,项目名称:yii-dressing,代码行数:22,代码来源:YdSetting.php

示例7: isset

 * @author Brett O'Donnell <cornernote@gmail.com>
 * @author Zain Ul abidin <zainengineer@gmail.com>
 * @copyright 2013 Mr PHP
 * @link https://github.com/cornernote/yii-audit-module
 * @license BSD-3-Clause https://raw.github.com/cornernote/yii-audit-module/master/LICENSE
 *
 * @package yii-audit-module
 */
echo '<tr>';
echo '<td>';
echo isset($data->old_value) ? $data->old_value : '&nbsp;';
echo isset($data->old_value) && isset($data->new_value) ? ' &gt; ' : '';
echo isset($data->new_value) ? $data->new_value : '&nbsp;';
echo '</td>';
echo '<td>';
echo Time::ago($data->created);
echo '</td>';
echo '<td>';
echo '<small>' . $data->created . '</small>';
echo '</td>';
echo '<td>';
if (Yii::app()->user->checkAccess('admin')) {
    echo $data->user_id && is_numeric($data->user_id) ? User::model()->findByPk($data->user_id)->getLink() : $data->user_id;
} else {
    echo $data->user_id && is_numeric($data->user_id) ? User::model()->findByPk($data->user_id)->name : $data->user_id;
}
echo '</td>';
if (Yii::app()->user->checkAccess('admin')) {
    echo '<td>';
    echo $data->audit ? $data->audit->getLink() : '';
    echo '</td>';
开发者ID:cornernote,项目名称:yii-embed-wordpress,代码行数:31,代码来源:__field_view.php


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