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


PHP timeAgo函数代码示例

本文整理汇总了PHP中timeAgo函数的典型用法代码示例。如果您正苦于以下问题:PHP timeAgo函数的具体用法?PHP timeAgo怎么用?PHP timeAgo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: saveComment

function saveComment($name, $hour, $mycomment)
{
    $atime = timeAgo($hour);
    $putComment = $name . ' | ' . $mycomment . ' | ' . $atime;
    $filename = $hour . ".comment";
    file_put_contents($filename, $putComment);
}
开发者ID:ramasubbaiya,项目名称:PHP_Term_1_Course_Work,代码行数:7,代码来源:util.php

示例2: bitsList

 public function bitsList($bits)
 {
     $html = '<ul>';
     $count = 2;
     foreach ($bits as $bit) {
         $settings = json_decode($bit->meta);
         $sampleCode = $bit->javascript ? $bit->javascript : ($bit->html ? $bit->html : ($bit->css ? $bit->css : false));
         if ($sampleCode) {
             $compressed = preg_replace("/\n/", '', preg_replace("/\t/", '', substr(base64_decode($sampleCode), 0, 200)));
             $sampleCode = '<pre class="sample-code">' . _html($compressed) . '</pre>';
         } else {
             $sampleCode = '';
         }
         if ($settings->bit_description) {
             $sampleCode = '<pre class="sample-code">' . _html($settings->bit_description) . '</pre>';
         }
         $klass = $count % 2 == 0 ? 'even' : 'odd';
         $html .= '<li class="' . $klass . '"><a href="' . home_url('code/bit/' . $bit->slug . '/' . $bit->latestVersion) . '" class="block-link">';
         $html .= '<div class="bit-title group">';
         $html .= '<p class="pull-left code-font">' . $settings->bit_title . ' <span>v' . $bit->latestVersion . '</span></p>';
         $html .= '<time class="pull-right" datetime="' . $bit->created . '">' . timeAgo($bit->created) . '</time>';
         $html .= '</div>';
         $html .= '<div class="bit-sample">';
         $html .= $sampleCode;
         $html .= '</div>';
         $html .= '</a></li>';
         $count++;
     }
     $html .= '</ul>';
     return $html;
 }
开发者ID:juanretamales,项目名称:Bits,代码行数:31,代码来源:format.php

示例3: displayLastCheckin

 public function displayLastCheckin()
 {
     if ($this->lastCheckInTime != null) {
         echo timeAgo($this->lastCheckInTime);
     } else {
         echo "unknown";
     }
 }
开发者ID:WillVandergrift,项目名称:Omega,代码行数:8,代码来源:device.php

示例4: jsonTimestampOut

function jsonTimestampOut($lastupdate, $offset = 0, $lang, $callback)
{
    if ($lastupdate) {
        header("Content-Type: text/plain; charset=UTF-8");
        $difference = timeAgo(time(), $lastupdate, $offset);
        $jsonData = json_encode(array('timestamp' => array('unix' => substr($lastupdate, 0, -1), 'string' => timestampString($lastupdate, $offset)), 'difference' => array('unix' => $difference, 'lang' => $lang, 'string' => timeAgoString($difference))));
        // JSONP request?
        if (isset($callback)) {
            return $callback . '(' . $jsonData . ')';
        } else {
            return $jsonData;
        }
    }
    return false;
}
开发者ID:duizendnegen,项目名称:OpenRailwayMap,代码行数:15,代码来源:timestamp.php

示例5: processPost

 function processPost($post)
 {
     global $MStudent;
     $student = $MStudent->getById($post['from']);
     $post['pic'] = $student['photo'];
     $post['name'] = $student['name'];
     $post['date'] = timeAgo($post['date']);
     $post['id'] = $post['id']->{'$id'};
     if ($post['parent'] != '') {
         $post['parent'] = $post['parent']->{'$id'};
     }
     $post['liked'] = false;
     foreach ($post['likes'] as $key => &$sub_array) {
         if ($sub_array['id'] == $post['from']) {
             $post['liked'] = true;
             break;
         }
     }
     $post['content'] = nl2br(autolink($post['content']));
     return $post;
 }
开发者ID:edwardshe,项目名称:sublite-1,代码行数:21,代码来源:SocialModel.php

示例6: json_decode

						$color = '#2B5B6A;';
					?>

					<div class="panel panel-default">
						<div class="panel-heading" style="background: <?=$color; ?>">
							<?php
							if ($newsItem['type'] === 'edited_description') {
								echo ($newsItem['user_id'] == $_SESSION['user']['id']) ? 'Jag' : "<a href=\"profile?view={$newsItem['user_id']}\">{$newsItem['username']}</a>"; ?> ändrade gruppens beskrivning.
							<?php }
							if ($newsItem['type'] === 'group_created') {
								echo ($newsItem['user_id'] == $_SESSION['user']['id']) ? 'Jag' : "<a href=\"profile?view={$newsItem['user_id']}\">{$newsItem['username']}</a>"; ?> skapade gruppen.
							<?php }
							if ($newsItem['type'] === 'invited') {
								$json = json_decode($newsItem['what'], true);
								echo ($newsItem['user_id'] == $_SESSION['user']['id']) ? 'Jag' : "<a href=\"profile?view={$newsItem['user_id']}\">{$newsItem['username']}</a>"; ?> bjöd in <a href="profile?view=<?=$json['id']; ?> " style="color: #FFFFFF;"><?=$json['username']; ?></a>.
							<?php }
							if ($newsItem['type'] === 'invite_request') { ?>
								<a href="profile?view={$newsItem['user_id']}" style="color: #FFFFFF;"><?=$newsItem['username']; ?></a> vill gå med i gruppen.
								<div class="panel-body">
									<button class="btn btn-info" onClick="window.location.replace('groups?view=<?=$_GET['view']; ?>&show=invite&requests');">Hantera</button>
								</div>
							<?php }
							if ($newsItem['type'] === 'rejected_invite') {
								echo ($newsItem['user_id'] == $_SESSION['user']['id']) ? 'Jag' : "<a href=\"profile?view={$newsItem['user_id']}\" style=\"color: #FFFFFF;\">{$newsItem['username']}</a>"; ?> ignorerade inbjudan.
							<?php } ?>
						</div>
						<div class="panel-footer">
							<?=timeAgo($newsItem['date']); ?>
						</div>
					</div>
					<?php } ?>
开发者ID:pesa0015,项目名称:greatnonsens,代码行数:31,代码来源:news.php

示例7: getLatestTweets

function getLatestTweets($count = 1)
{
    $consumerKey = get_field('twitter_consumer_key', 'option');
    $consumerSecret = get_field('twitter_consumer_secret', 'option');
    $accessToken = get_field('twitter_access_token', 'option');
    $accessSecret = get_field('twitter_access_token_secret', 'option');
    $connection = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken, $accessSecret);
    $tweetData = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=atticoos&count={$count}");
    $tweets = array();
    foreach ($tweetData as $tweet) {
        $replace_index = array();
        if (!empty($tweet->entities)) {
            foreach ($tweet->entities as $area => $items) {
                switch ($area) {
                    case 'hashtags':
                        $find = 'text';
                        $prefix = '#';
                        $url = 'https://twitter.com/search/?src=hash&q=%23';
                        break;
                    case 'user_mentions':
                        $find = 'screen_name';
                        $prefix = '@';
                        $url = 'https://twitter.com/';
                        break;
                    case 'media':
                    case 'urls':
                        $find = 'display_url';
                        $prefix = '';
                        $url = '';
                        break;
                    default:
                        break;
                }
                foreach ($items as $item) {
                    $text = $tweet->text;
                    $string = $item->{$find};
                    $href = $url . $string;
                    if (!(strpos($href, 'http://') === 0) && !(strpos($href, 'https://') === 0)) {
                        $href = 'http://' . $href;
                    }
                    $replace = substr($text, $item->indices[0], $item->indices[1] - $item->indices[0]);
                    $with = "<a href=\"{$href}\" target=\"_blank\">{$prefix}{$string}</a>";
                    $replace_index[$replace] = $with;
                }
            }
            foreach ($replace_index as $replace => $with) {
                $tweet->text = str_replace($replace, $with, $tweet->text);
            }
        }
        $tweets[] = array('user' => $tweet->user, 'id' => $tweet->id, 'text' => $tweet->text, 'createdat' => $tweet->created_at, 'timeago' => timeAgo(strtotime($tweet->created_at)));
    }
    return $tweets;
}
开发者ID:ajwhite,项目名称:Portfolio,代码行数:53,代码来源:functions.php

示例8: getStats

 /**
  * Echoes the stats of the cache.
  *
  * Gives the cache hits, cache misses and cache uptime.
  *
  * @since 6.2.0
  */
 public function getStats()
 {
     if (!$this->enable) {
         return false;
     }
     echo "<p>";
     echo "<strong>" . _t('Cache Hits:') . "</strong> " . _file_get_contents($this->_dir . 'cache_hits.txt') . "<br />";
     echo "<strong>" . _t('Cache Misses:') . "</strong> " . _file_get_contents($this->_dir . 'cache_misses.txt') . "<br />";
     echo "<strong>" . _t('Uptime:') . "</strong> " . timeAgo(file_mod_time($this->_dir)) . "<br />";
     echo "</p>";
 }
开发者ID:parkerj,项目名称:eduTrac-SIS,代码行数:18,代码来源:etsis_Cache_Cookie.php

示例9: getDataSourceLogs

 /**
  * getDataSourceLogs
  * @author Minh Duc Nguyen <minh.nguyen@ands.org.au>
  * @param [POST] data_source_id [POST] offset [POST] count [POST] log_id
  * 
  * @return [json] [logs for the data source]
  */
 public function getDataSourceLogs()
 {
     header('Cache-Control: no-cache, must-revalidate');
     header('Content-type: application/json');
     // date_default_timezone_set('Australia/Canberra');//???
     $this->load->model('data_sources', 'ds');
     $post = $this->input->post();
     $id = isset($post['id']) ? $post['id'] : 0;
     //data source id
     if ($id == 0) {
         throw new Exception('Data Source ID must be provided');
         exit;
     }
     $offset = isset($post['offset']) ? (int) $post['offset'] : 0;
     $count = isset($post['count']) ? (int) $post['count'] : 10;
     $logid = isset($post['logid']) ? (int) $post['logid'] : null;
     $log_class = isset($post['log_class']) ? $post['log_class'] : 'all';
     $log_type = isset($post['log_type']) ? $post['log_type'] : 'all';
     $jsonData = array();
     $dataSource = $this->ds->getByID($id);
     $dataSourceLogs = $dataSource->get_logs($offset, $count, $logid, $log_class, $log_type);
     $jsonData['log_size'] = $dataSource->get_log_size($log_type);
     if ($jsonData['log_size'] > $offset + $count) {
         $jsonData['next_offset'] = $offset + $count;
         $jsonData['hasMore'] = true;
     } else {
         $jsonData['next_offset'] = 'all';
         $jsonData['hasMore'] = false;
     }
     $jsonData['last_log_id'] = '';
     $lastLogIdSet = false;
     $items = array();
     if (sizeof($dataSourceLogs) > 0) {
         foreach ($dataSourceLogs as $log) {
             $item = array();
             $item['type'] = $log['type'];
             $item['log_snippet'] = first_line($log['log']);
             $item['log'] = $log['log'];
             $item['id'] = $log['id'];
             if (!$lastLogIdSet) {
                 $jsonData['last_log_id'] = $log['id'];
                 $lastLogIdSet = true;
             }
             $item['date_modified'] = timeAgo($log['date_modified']);
             $item['harvester_error_type'] = $log['harvester_error_type'];
             if ($log['harvester_error_type'] != 'BENCHMARK_INFO' || $this->user->hasFunction(AUTH_FUNCTION_SUPERUSER)) {
                 array_push($items, $item);
             }
         }
     }
     $jsonData['count'] = $count;
     $jsonData['items'] = $items;
     echo json_encode($jsonData);
 }
开发者ID:aaryani,项目名称:RD-Switchboard-Net,代码行数:61,代码来源:data_source.php

示例10: viewData

 function viewData($c, $entry = NULL)
 {
     global $MMessage;
     $messages = array_reverse(iterator_to_array($MMessage->findByParticipant($_SESSION['_id']->{'$id'})));
     $replies = array();
     $unread = 0;
     foreach ($messages as $m) {
         $reply = array_pop($m['replies']);
         $reply['_id'] = $m['_id'];
         $from = $reply['from'];
         if (!$reply['read']) {
             $reply['read'] = strcmp($from, $_SESSION['_id']) == 0;
         }
         if (!$reply['read']) {
             $unread++;
         }
         $c->setFromNamePic($reply, $from);
         if (strcmp($m['_id'], $entry['_id']) == 0) {
             $reply['current'] = true;
         } else {
             $reply['current'] = false;
         }
         $reply['time'] = timeAgo($reply['time']);
         if (strlen($reply['msg']) > 100) {
             $reply['msg'] = substr($reply['msg'], 0, 97) . '...';
         }
         array_push($replies, $reply);
     }
     // Handle current message
     if (!is_null($entry)) {
         $currentreplies = $entry['replies'];
         $current = array();
         foreach ($currentreplies as $m) {
             $c->setFromNamePic($m, $m['from']);
             $m['time'] = timeAgo($m['time']);
             array_push($current, $m);
         }
         $to = 'Message To: ' . $c->getName($entry['participants'][0]);
         foreach ($entry['participants'] as $p) {
             if (strcmp($p, $_SESSION['_id']) != 0) {
                 $to = 'Message To: ' . $c->getName($p);
             }
         }
         $currentid = $entry['_id'];
     } else {
         $current = null;
         $currentid = null;
         $to = '';
     }
     $data = array('messages' => $replies, 'current' => $current, 'currentid' => $currentid, 'unread' => $unread, 'to' => $to);
     if (isset($_GET['msg'])) {
         $data['msg'] = $_GET['msg'];
     }
     return $data;
 }
开发者ID:edwardshe,项目名称:sublite-1,代码行数:55,代码来源:MessageController.php

示例11: foreach





<?php 
    foreach ($answers as $answer) {
        ?>

<div class="questionsview_userbox">
<?php 
        echo getUser($answer['userid']);
        ?>
</div>

<div class="questionsview_details"><span style="color:#999"><?php 
        echo timeAgo(strtotime($answer['created']));
        ?>
</span>
</div>

<?php 
        if ($answer['userid'] == $_SESSION['userid']) {
            ?>
<div class="questionsview_options"><a href="<?php 
            echo basePath();
            ?>
/answers/edit/<?php 
            echo $answer['id'];
            ?>
">edit</a></div>
<?php 
开发者ID:bg6aer,项目名称:Qwench,代码行数:27,代码来源:view.php

示例12: timeAgo

img/avatar04.png" alt="Avatar Image" >
								</a>
								 <p style="float:right; text-align:right; font-size:10px;"><a href="javascript:;" rel="<?php 
        echo $post_id;
        ?>
" class="comment-delete" id="comment_delete_<?php 
        echo $comment_id;
        ?>
">X</a></p>
								</div>
								<div class="acomment-meta">
								<a href="#" ><?php 
        echo $fulln;
        ?>
</a>  <?php 
        echo timeAgo($comt['commented_date']);
        ?>
 
								</div>
								<div class="acomment-content"><p class="msg_wrap"><?php 
        echo parse_smileys(make_clickable(nl2br(stripslashes($comt['comment']))), $smiley_folder);
        ?>
</p></div></li>
								<?php 
    }
    ?>
								</ul>
								<?php 
    if ($total_topics == 0) {
        ?>
								<!--- Topic Code  --->
开发者ID:Entellus,项目名称:System,代码行数:31,代码来源:share.php

示例13: timeAgo

    echo $repo->html_url;
    ?>
"><?php 
    echo $repo->name;
    ?>
</a> <small><?php 
    echo $repo->collaborator_count;
    ?>
 Contributors</small>
								</h2>
								<p><?php 
    echo $repo->description;
    ?>
</p>
								<p><?php 
    echo "Last updated " . timeAgo($repo->pushed_at);
    ?>
</p>
							</div>
						</div>
<?php 
}
?>

</div>
				</div>
			</div>
		</div>
		<?php 
$this->load->view('include/social_sidebar.php');
?>
开发者ID:kronus7713,项目名称:web2015,代码行数:31,代码来源:projects.php

示例14: timeAgo

"
		<?php 
        }
        ?>
 alt="user photo" class="media-object img-circle width-50" style="height: 50px;" />
                    </div>
                    <div class="media-body message">
                      <h4 class="text-subhead margin-none"><a href="user_view?username=<?php 
        echo $row['sender'];
        ?>
"><?php 
        echo $row['sender'];
        ?>
</a></h4>
                      <p class="text-caption text-light"><i class="fa fa-clock-o"></i> <?php 
        echo timeAgo($row['time']);
        ?>
</p>
                    </div>
                  </div>
                  <p><?php 
        echo $row['message'];
        ?>
</p>
                </div>
              </div>
	<?php 
    }
    //end of while loop
} else {
    ?>
开发者ID:Osademe-e,项目名称:knotandrings,代码行数:31,代码来源:message_load.php

示例15: formPosts

/**
 * Creates an array of posts in a format to print on the page given a mysql
 * reponse of posts.
 */
function formPosts($rows)
{
    $posts = [];
    foreach ($rows as $row) {
        $users = Lib::query("SELECT * FROM users WHERE id = ?", $row["user_id"]);
        $user = $users[0];
        //first and only user
        $votes = Lib::query("SELECT * FROM votes WHERE post_id = ?", $row["id"]);
        $numberLikes = count($votes);
        $userVotes = Lib::query("SELECT * FROM votes WHERE post_id = ? AND user_id = ?", $row["id"], $_SESSION["id"]);
        $liked = false;
        if (count($userVotes) == 1) {
            $liked = true;
        }
        $topics = Lib::query("SELECT * FROM topics WHERE id = ?", $row["topic_id"]);
        $topic = $topics[0];
        $posts[] = ["id" => $row["id"], "user" => $user, "date" => timeAgo(strtotime($row["date"])), "text" => $row["text"], "likes" => $numberLikes, "liked" => $liked, "topic" => $topic];
    }
    return $posts;
}
开发者ID:tomkoker,项目名称:thenetwork,代码行数:24,代码来源:helpers.php


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