本文整理汇总了PHP中timeago函数的典型用法代码示例。如果您正苦于以下问题:PHP timeago函数的具体用法?PHP timeago怎么用?PHP timeago使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了timeago函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: my_events
function my_events()
{
$query = mysql_query("SELECT DISTINCT * FROM events, users WHERE events.uid = users.uid AND events.event_time > UNIX_TIMESTAMP(NOW()) AND events.uid != '" . $_SESSION['uid'] . "' ORDER BY events.loc_zip ASC LIMIT 100 ");
$counter = 0;
while ($row = mysql_fetch_array($query)) {
$tags = "";
foreach (explode(',', $row['event_tags']) as $Characteristics) {
$tags .= '<span class="label">' . $Characteristics . '</span> ';
}
echo '<table width="100%">
<tr>
<th>
<b>' . $row['event_name'] . '</b>
<table width="100%" style="border: solid 0px #dddddd">
<tr>
<th width="50px"><i class="fa fa-' . $row['event_category'] . ' fa-5x"></i></th>
<th>' . $row['event_info'] . '<br> By: ' . $row['fname'] . ' ' . substr($row['lname'], 0, 1) . '.<br>' . $tags . '</th>
</tr>
</table>
</th>
<th width="50px"><center><h5><b>' . $row['loc_zip'] . ' miles</b></h5><a href="#JoinEvent&id=' . $row['id'] . '" class="radius small button">Join Event</a>' . timeago($row[event_time]) . '</h5></center></th>
</tr>
</table>';
$counter++;
}
if ($counter == 0) {
echo "</ul></div><hr><center><font color='red'>We found no results.</font><hr>";
} elseif ($counter == 100) {
echo "</ul></div><hr><center><font color='red'>Limited to 100 results....</font><center><hr>";
}
}
示例2: widget
/**
* 小工具的渲染方法,这里就是输出评论
*/
function widget($args, $instance)
{
global $wpdb, $comments, $comment;
$cache = wp_cache_get('f_comment', 'widget');
if (!is_array($cache)) {
$cache = array();
}
if (!isset($args['widget_id'])) {
$args['widget_id'] = $this->id;
}
if (isset($cache[$args['widget_id']])) {
echo $cache[$args['widget_id']];
return;
}
extract($args, EXTR_SKIP);
$output = '';
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments') : $instance['title'], $instance, $this->id_base);
if (empty($instance['number']) || !($number = absint($instance['number']))) {
$number = 5;
}
//获取评论,过滤掉管理员自己
$comments = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE user_id !=1 and comment_approved = '1' and comment_type not in ('pingback','trackback') ORDER BY comment_date_gmt DESC LIMIT {$number}");
$output .= $before_widget;
if ($title) {
$output .= $before_title . $title . $after_title;
}
$output .= '<div class="all-comments">';
if ($comments) {
// Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)
$post_ids = array_unique(wp_list_pluck($comments, 'comment_post_ID'));
_prime_post_caches($post_ids, strpos(get_option('permalink_structure'), '%category%'), false);
foreach ((array) $comments as $comment) {
if ($comment->comment_author_email != $my_email) {
//头像
$avatar = get_avatar($comment, 36);
//作者名称
$author = get_comment_author();
//评论内容
$content = apply_filters('get_comment_text', $comment->comment_content);
$content = mb_strimwidth(strip_tags($content), 0, '65', '...', 'UTF-8');
$content = convert_smilies($content);
//评论的文章
$post = '<a href="' . esc_url(get_comment_link($comment->comment_ID)) . '">' . $avatar . $author . '<span class="muted">' . timeago($comment->comment_date_gmt) . ':<br>' . $content . '</span></a>';
//这里就是输出的html,可以根据需要自行修改
$output .= $post;
}
}
}
$output .= '</div>';
$output .= $after_widget;
echo $output;
$cache[$args['widget_id']] = $output;
wp_cache_set('my_widget_recent_comments', $cache, 'widget');
}
示例3: terakhir_tunup
function terakhir_tunup($kendaraan_id)
{
$this->db->where('servis.kendaraan', $kendaraan_id);
$this->db->where('servis_detail.komponen', 'KOM-28');
$this->db->join('servis_detail', 'servis.nomor=servis_detail.servis', 'left');
$this->db->order_by('servis.tanggal', 'desc');
$this->db->limit(1);
$result = $this->db->get('servis');
if ($result->num_rows() > 0) {
return timeago(strtotime($result->row()->tanggal));
} else {
return "Belum Pernah Tuneup";
}
}
示例4: widget
function widget($args, $instance)
{
extract($args);
$title = apply_filters('widget_name', $instance['title']);
$limit = $instance['limit'];
$outer = $instance['outer'];
if (!$outer) {
$outer = -1;
}
echo $before_widget;
echo $before_title . $title . $after_title;
echo '<ul>';
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved,comment_author_email, comment_type,comment_author_url, SUBSTRING(comment_content,1,60) AS com_excerpt FROM {$wpdb->comments} LEFT OUTER JOIN {$wpdb->posts} ON ({$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID) WHERE user_id!='" . $outer . "' AND comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT {$limit}";
$comments = $wpdb->get_results($sql);
foreach ($comments as $comment) {
$output .= $comment->user_id . '<li><a' . hui_target_blank() . ' href="' . get_permalink($comment->ID) . '#comment-' . $comment->comment_ID . '" title="' . $comment->post_title . __('上的评论', 'haoui') . '">' . hui_get_avatar($user_id = $comment->user_id, $user_email = $comment->comment_author_email) . strip_tags($comment->comment_author) . ' <span class="text-muted">' . timeago($comment->comment_date_gmt) . __('说:', 'haoui') . '<br>' . str_replace(' src=', ' data-original=', convert_smilies(strip_tags($comment->com_excerpt))) . '</span></a></li>';
}
echo $output;
echo '</ul>';
echo $after_widget;
}
示例5: userdata
<a href="#" class="activity-user-name"><?php
echo userdata(usuario_nombre, $muro[id_autor]);
?>
</a>
<?php
if ($muro[tipo] == 5) {
echo $var;
}
?>
<span>
</span>
<span class="activity-time-ago"><?php
echo timeago(strtotime($muro['fecha']));
?>
</span>
</div>
<div class="activity-content-desc">
<!-- Contenido de la actividad (descripcion) -->
<?php
if ($muro[tipo] != 5 and $muro[tipo] != 6) {
echo $muro["contenido"];
}
?>
</div>
<!-- Descripcion de la actividad -->
示例6: xss
$rtimes[$b] = $mid;
$mid = $rnames[$b - 1];
$rnames[$b - 1] = $rnames[$b];
$rnames[$b] = $mid;
$b--;
}
}
function xss($val)
{
$val = str_replace("&", "&", $val);
$val = str_replace("<", "<", $val);
$val = str_replace(">", ">", $val);
$val = str_replace('"', """, $val);
$val = str_replace("'", "'", $val);
$val = str_replace("/", "/", $val);
return $val;
}
for ($j = count($rtimes) - 1; $j >= 0; $j--) {
$cmp = json_decode(file_get_contents("./data/comps/" . $rnames[$j]));
echo "<tr>";
echo "<td><a href='./comp/?" . substr($rnames[$j], 0, -5) . "'>" . xss($cmp->name) . "</a></td>";
echo "<td>" . count($cmp->rows) . "</td>";
echo "<td>" . timeago($rtimes[$j]) . "</td>";
echo "<td>" . xss($cmp->date) . "</td>";
if (isset($cmp->region)) {
echo "<td><a href='./region/?" . str_replace(" ", "", strtolower($cmp->region)) . "'>" . xss($cmp->region) . "</a></td>";
} else {
echo "<td></td>";
}
echo "</tr>";
}
示例7: mod_newcomments
function mod_newcomments($limit, $outpost, $outer)
{
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved,comment_author_email, comment_type,comment_author_url, SUBSTRING(comment_content,1,40) AS com_excerpt FROM {$wpdb->comments} LEFT OUTER JOIN {$wpdb->posts} ON ({$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID) WHERE comment_post_ID!='" . $outpost . "' AND user_id!='" . $outer . "' AND comment_approved = '1' AND comment_type = '' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT {$limit}";
$comments = $wpdb->get_results($sql);
foreach ($comments as $comment) {
$output .= '<li><a href="' . get_permalink($comment->ID) . '#comment-' . $comment->comment_ID . '" title="' . $comment->post_title . '上的评论">' . str_replace(' src=', ' data-original=', get_avatar($comment->comment_author_email, $size = '36', deel_avatar_default())) . ' <div class="muted"><i>' . strip_tags($comment->comment_author) . '</i>' . timeago($comment->comment_date_gmt) . '说:' . str_replace(' src=', ' data-original=', convert_smilies(strip_tags($comment->com_excerpt))) . '</div></a></li>';
}
echo $output;
}
示例8: getName
?>
<img height="50px" width="50px" src="<?php
echo $photo_unread_msg;
?>
" alt="">
</div>
<div class="thread-content">
<span class="author"><?php
echo getName($m->sender_id);
?>
</span>
<span class="preview"><?php
echo word_limiter($m->message, 30);
?>
</span>
<span class="time"> <?php
echo timeago($m->sent_on);
?>
</span>
</div>
</div>
</a>
</li>
<?php
}
} else {
echo "<span>Tidak ada pesan baru</span>";
}
?>
</ul>
</div>
示例9: mysql_query
<ul id="mn-ls-messages" class="gadget-ct mn-ls-messages">
<?php
$result = mysql_query("SELECT * FROM mensajes WHERE (usuario_recibe = " . userinfo(usuario_id) . " and usuario_envia = " . $id . ") or (usuario_envia = " . userinfo(usuario_id) . " and usuario_recibe = " . $id . ") ORDER BY fecha ASC") or die(mysql_error());
while ($msg = mysql_fetch_array($result)) {
?>
<li>
<a class="circle-picture mn-ls-user-profile" href="#"><img src="<?php
echo userdata(avatar, $msg["usuario_envia"]);
?>
" alt=""></a>
<a class="mn-ls-content" href="#">
<h5><?php
echo userdata(usuario_nombre, $msg["usuario_envia"]);
?>
<span><?php
echo timeago(strtotime($msg["fecha"]));
?>
</span></h5>
<p><?php
echo $msg["contenido"];
?>
</p>
</a>
</li>
<?php
}
?>
</ul>
</div>
示例10: timeago
" title="<?php
echo $value['log_title'];
?>
" target=_blank><?php
echo $value['log_title'];
?>
</a><?php
if ($value['top'] == 'y' || $value['sortop'] == 'y') {
echo ' <i class="fa fa-arrow-up"></i>';
}
?>
</h2>
</header>
<p class="article_exp_meta">
<time class="article_exp_time"><i class="fa fa-clock-o"></i> <?php
echo timeago($value['date'], true);
?>
</time>
<span class="article_exp_pv"><i class="fa fa-eye"></i> 阅读(<?php
echo $value['views'];
?>
)</span>
<a href="<?php
echo $value['log_url'];
?>
#comments" class="article_exp_cmt"><i class="fa fa-comments-o"></i> 评论(<?php
echo $value['comnum'];
?>
)</a>
<?php
editflg($value['logid'], $value['author']);
示例11: fun_comment
function fun_comment($comment, $args, $depth)
{
$GLOBALS['comment'] = $comment;
?>
<li <?php
comment_class();
?>
id="comment-<?php
comment_ID();
?>
">
<div id="div-comment-<?php
comment_ID();
?>
" class="comment-body">
<?php
echo fun_get_avatar($comment->user_id, '54', fun_get_avatar_type($comment->user_id));
?>
<?php
$add_below = 'div-comment';
?>
<div class="comment-main">
<?php
if ($comment->comment_approved == '0') {
?>
<span style="color:#C00; font-style:inherit; margin-top:5px; line-height:25px;"><?php
$cpid = $comment->comment_parent;
if ($cpid != 0) {
echo '@';
}
comment_author_link($cpid);
_e('您的评论正在等待审核中...', 'tinection');
?>
</span>
<br />
<?php
}
?>
<?php
if ($comment->comment_approved == '1') {
?>
<?php
comment_text();
?>
<?php
}
?>
<div class="comment-author">
<div class="comment-info">
<span class="comment_author_link"><?php
if ($comment->user_id != 0) {
echo '<a href="' . get_author_posts_url($comment->user_id) . '" class="name">' . $comment->comment_author . '</a>';
} else {
comment_author_link();
}
?>
</span>
<?php
if (ot_get_option('comment_vip') == 'on') {
get_author_class($comment->comment_author_email, $comment->user_id);
}
?>
<?php
if (ot_get_option('comment_ua') == 'on') {
echo outputbrowser($comment->comment_agent);
}
?>
<?php
if (ot_get_option('comment_ip') == 'on') {
?>
<span class="comment_author_ip tooltip-trigger" title="<?php
echo sprintf(__('来自%1$s', 'tinection'), convertip(get_comment_author_ip()));
?>
"><img class="ip_img" src="<?php
echo THEME_URI . '/images/ua/ip.png';
?>
"></span><?php
}
?>
<span class="datetime">
<?php
echo timeago(get_gmt_from_date(get_comment_date('Y-m-d G:i:s')));
?>
</span>
<span class="reply">
<?php
if (is_user_logged_in()) {
comment_reply_link(array_merge($args, array('reply_text' => __('回复', 'tinection'), 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'])));
} else {
echo '<a rel="nofollow" class="comment-reply-login user-login" href="javascript:">' . __('登录以回复', 'tinection') . '</a>';
}
?>
</span>
<span class="cmt-vote">
<?php
$c_name = 'fun_comment_vote_' . $comment->comment_ID;
$cookie = isset($_COOKIE[$c_name]) ? $_COOKIE[$c_name] : '';
?>
<i class="fa fa-thumbs-o-up <?php
if ($cookie == 1) {
//.........这里部分代码省略.........
示例12: blog_comments_children
function blog_comments_children($comments, $children)
{
$isGravatar = Option::get('isgravatar');
foreach ($children as $child) {
$comment = $comments[$child];
$isNofollow = $comment['url'] && $comment['url'] != BLOG_URL ? 'rel="nofollow"' : '';
$comment['poster'] = $comment['url'] ? '<a href="' . $comment['url'] . '" target="_blank" ' . $isNofollow . '>' . $comment['poster'] . '</a>' : $comment['poster'];
?>
<div class="comment comment-children" id="comment-<?php
echo $comment['cid'];
?>
">
<a name="<?php
echo $comment['cid'];
?>
"></a>
<?php
if ($isGravatar == 'y') {
echo '<div class="avatar"><img src="' . TEMPLATE_URL . 'images/0.gif" data-src="' . J_getGravatar($comment['mail']) . '" /></div>';
} else {
echo '<div class="avatar"><img src="' . TEMPLATE_URL . 'images/noAvator.jpg" /></div>';
}
?>
<div class="comment-info">
<div class="comment-content"><?php
echo comment2emoji($comment['content']);
?>
</div>
<div class="comment-meata">
<span class="comment-poster"><?php
echo $comment['poster'];
?>
</span>
<span class="comment-time"><?php
if (strtotime($comment['date'])) {
echo timeago(strtotime($comment['date']));
} else {
echo str_replace(' ', '', $comment['date']);
}
?>
</span>
<?php
if ($comment['level'] < 3) {
echo '<a href="#comment-' . $comment['cid'] . '" onclick="commentReply(' . $comment['cid'] . ',this)" class="comment-reply-btn">回复</a>';
}
?>
</div>
</div>
<?php
blog_comments_children($comments, $comment['children']);
?>
</div>
<?php
}
}
示例13: detail
public function detail($id)
{
$xdata['breadcrumb'] = 'kendaraan' . $this->_filter();
$xdata['kendaraan'] = $this->kendaraan_mdl->get_from_field('kendaraan.id', $id, 1)->row();
//servis detail
$this->table->set_template(tbl_tmp_servis());
$this->table->set_heading('No', 'Tanggal', 'Lama', 'Komponen Mesin', 'Jenis Perlakuan');
$servis_history = $this->general_mdl->get_servis_history($xdata['kendaraan']->kode)->result();
$i = 1;
foreach ($servis_history as $r) {
$this->table->add_row($i++, format_dmy($r->tanggal), timeago(strtotime($r->tanggal)), $r->komponen_lain != '' ? $r->komponen_lain : $r->komponen_nama, $r->servis_aksi_nama);
}
$xdata['servis_history'] = $this->table->generate();
$data['content'] = $this->load->view('kendaraan_detail', $xdata, true);
$this->load->view('template', $data);
}
示例14: hui_comment_list
function hui_comment_list($comment, $args, $depth)
{
echo '<li ';
comment_class();
echo ' id="comment-' . get_comment_ID() . '">';
echo '<div class="c-avatar">' . hui_get_avatar($comment->user_id, $comment->comment_author_email) . '</div>';
echo '<div class="c-main" id="div-comment-' . get_comment_ID() . '">';
echo '<span class="c-author">' . get_comment_author_link() . '</span>';
echo str_replace(' src=', ' data-original=', convert_smilies(get_comment_text()));
if ($comment->comment_approved == '0') {
echo '<span class="c-approved">' . __('待审核', 'haoui') . '</span>';
}
echo '<time class="c-time">' . timeago($comment->comment_date) . '</time>';
if ($comment->comment_approved !== '0') {
echo comment_reply_link(array_merge($args, array('add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth'])));
}
echo '</div>';
}
示例15: sizeof
<section>
<h3>Latest changes to this page:</h3>
<p>Tweets take 15-30 seconds to appear.</p>
<ul><?php
$i = 0;
$count = sizeof($results->statuses);
$style_array = [];
if ($count == 0) {
echo "Nobody has tweeted to @css_tweet recently, but you still can!";
}
foreach ($results->statuses as $result) {
$text = formattweet($result->text);
$username = $result->user->name;
$handle = $result->user->screen_name;
$time = timeago($result->created_at);
$handle = $result->user->screen_name;
$image = $result->user->profile_image_url;
$link = $result->id_str;
$style = '<style style="display:none;" id="tweet-' . $link . '">' . $text . '</style>';
echo '<li>';
echo '<div style="display: block;">' . $text . '</div>';
echo '<a href="http://twitter.com/' . $handle . '">' . $username . '</a> ';
echo '<time><a href="http://twitter.com/' . $handle . '/status/' . $link . '">' . $time . '</a></time> ';
echo '<button onclick="this.parentNode.remove();document.getElementById(\'tweet-' . $link . '\').remove();">Hide</button>';
echo '</li>';
array_unshift($style_array, $style);
$i++;
if ($i == $count) {
foreach ($style_array as $style) {
echo $style;