本文整理汇总了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);
}
}
示例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);
}
示例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');
}
示例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);
}
示例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);
}
示例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;
}
示例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 : ' ';
echo isset($data->old_value) && isset($data->new_value) ? ' > ' : '';
echo isset($data->new_value) ? $data->new_value : ' ';
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>';