本文整理汇总了PHP中time_elapsed_string函数的典型用法代码示例。如果您正苦于以下问题:PHP time_elapsed_string函数的具体用法?PHP time_elapsed_string怎么用?PHP time_elapsed_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了time_elapsed_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUpdateTimeAttribute
public function getUpdateTimeAttribute()
{
if ($this->updated_at != NULL) {
return time_elapsed_string($this->updated_at);
}
return '';
}
示例2: add
public function add()
{
if ($this->session->userdata('id') != '') {
$user_id = $this->session->userdata('id');
} else {
$user_id = 0;
}
if ($this->session->userdata('id') != '') {
$user_name = $this->session->userdata('username');
} else {
$user_name = '';
}
//adding notes in project notes
$time_ago = time_elapsed_string(strtotime(date("Y-m-d H:i:s")));
$data_notes = array('news_id' => $this->input->post('news_id'), 'comment' => $this->input->post('news_comment'), 'comment_by' => $user_id, 'created_date' => date("Y-m-d H:i:s"));
if ($this->comment_model->add_comment($data_notes, TRUE)) {
$response = array('status' => 'success', 'msg' => 'Your notes has been successfully added', 'comment' => $this->input->post('news_comment'), 'username' => $user_name, 'time' => $time_ago);
echo json_encode($response);
die;
} else {
$response = array('status' => 'fail', 'msg' => 'Oops!Something Wrong!');
echo json_encode($response);
die;
}
}
示例3: timeElapsed
public function timeElapsed()
{
if ($this->value) {
return time_elapsed_string($this->value);
}
return null;
}
示例4: index
public function index()
{
$news_list = $this->news_model->get_all();
foreach ($news_list as $key => $val) {
$news_list[$key]['time_ago'] = time_elapsed_string(strtotime($val['created_date']));
}
$data['news_list'] = $news_list;
$this->template->load('admin_default', 'news/index', $data);
}
示例5: index
public function index()
{
$news_list = $this->news_model->get_all();
foreach ($news_list as $key => $val) {
$news_list[$key]['time_ago'] = time_elapsed_string(strtotime($val['created_date']));
}
$user_id = $this->session->userdata('id');
$data['news_list'] = $news_list;
$data['products'] = $this->products_model->getfrom('products_new');
$data['projects'] = $this->products_model->getfrom('projects', false, array('where' => array('priority' => '1')));
$this->template->load('admin_default', 'dashboard/index', $data);
}
示例6: topic_detail
public function topic_detail($topicId)
{
$topic = Topic::find($topicId);
$topic->author;
$topic->remain_time = time_remain_string(strtotime($topic->deadline));
$topic->time_create = time_elapsed_string(strtotime($topic->created_at));
$topic->submits = count(array_unique($topic->products->pluck('author_id')->toArray()));
$topic->all_products = $topic->products()->orderBy('created_at', 'desc')->get();
foreach ($topic->all_products as &$product) {
$product->liked = isset($this->user) && $this->user->likes()->where('product_id', $product->id)->count() > 0;
$product->author->url = url('profile/' . get_first_part_of_email($product->author->email));
$product->created_time = time_elapsed_string(strtotime($product->created_at));
$product->author->avatar_url = $product->author->avatar_url != null ? $product->author->avatar_url : url('img/user.png');
$product->count_likes = $product->likes()->count();
$product->count_comments = $product->comments()->count();
$product->link = url('post/colormevn-' . convert_vi_to_en($product->description) . '?id=' . $product->id);
}
unset($topic->products);
return response()->json($topic, 200);
}
示例7: transform
public function transform($notification)
{
$data = ['id' => $notification->id, 'receiver' => ['id' => $notification->receiver->id, 'avatar_url' => $notification->receiver->avatar_url == null ? url('img/user.png') : $notification->receiver->avatar_url, 'name' => $notification->receiver->name, 'username' => $notification->receiver->username], 'actor' => ['id' => $notification->actor->id, 'avatar_url' => $notification->actor->avatar_url == null ? url('img/user.png') : $notification->actor->avatar_url, 'name' => $notification->actor->name, 'username' => $notification->actor->username], 'created_at' => time_elapsed_string(strtotime($notification->created_at)), 'seen' => $notification->seen == 1];
if ($notification->type <= 2 && $notification->type >= 0) {
// if ($notification->product == null) {
// $notification->delete();
// }
$data['product'] = ['id' => $notification->product->id, 'linkId' => $notification->product->name ? convert_vi_to_en($notification->product->name) . "-" . $notification->product->id : "bai-tap-colorme-" . $notification->product->id];
} else {
if ($notification->type == 3 || $notification->type == 4) {
$data['transaction'] = ['id' => $notification->transaction->id, 'status' => $notification->transaction->status, 'money' => currency_vnd_format($notification->transaction->money)];
if ($notification->transaction->status != 0 && $notification->type == 3) {
$notification->type = 4;
$notification->save();
}
} else {
if ($notification->type == 5) {
$data['topic'] = ['id' => $notification->topic->id];
}
}
}
$data['type'] = notification_type($notification->type);
return $data;
}
示例8: foreach
<div class="widget widget_tweets">
<h4 class="widget-title"><?php
echo $langs['latest_news'];
?>
</h4>
<ul id="twitter">
<?php
foreach ($news as $item) {
?>
<li>
<span><?php
echo $item['text'];
?>
</span>
<b><a href="#"><?php
echo time_elapsed_string($item['date_created']);
?>
</a></b>
</li>
<?php
}
?>
</ul>
</div>
<?php
}
?>
</aside>
</div>
示例9: get_author_posts_url
echo get_author_posts_url($userId);
?>
">
<?php
echo $user_info->user_login;
?>
</a>
<a href="<?php
echo get_author_posts_url($userId);
?>
"> <span>@<?php
echo $user_info->user_login;
?>
- <?php
echo time_elapsed_string($post_notification_time);
?>
</span></a>
<?php
if ($post_like == like) {
?>
<strong><a href="<?php
echo get_permalink($postIds);
// echo get_tag_link($tagid);
?>
">Is praying for #<?php
echo $tagname;
?>
post</a></strong>
<?php
示例10: foreach
</div>
<div class="panel-body">
<?php
if ($pendingReserves) {
?>
<ul class="list-group">
<?php
foreach ($pendingReserves as $res) {
?>
<li class="list-group-item">
<b><?php
echo anchor('request-view', $res['item'], array('id' => $res['id']));
?>
</b>
<span class="myinfo alert-warning"><?php
echo time_elapsed_string($res['dt_request']);
?>
</span>
<span class="badge alert-danger"><?php
echo $statusList[$res['status']];
?>
</span>
</li>
<?php
}
?>
</ul>
<?php
echo anchor('res-reserves', 'View all →');
?>
<?php
示例11: time_elapsed_string
* These two variables are provided for context:
* - $comment: Full comment object.
* - $node: Node object the comments are attached to.
*
* Other variables:
* - $classes_array: Array of html class attribute values. It is flattened
* into a string within the variable $classes.
*
* @see template_preprocess()
* @see template_preprocess_comment()
* @see template_process()
* @see theme_comment()
*
* @ingroup themeable
*/
$since_created = time_elapsed_string($comment->created);
?>
<div class="<?php
print $classes;
?>
clearfix"<?php
print $attributes;
?>
>
<div class="content <?php
if ($new) {
?>
new<?php
}
?>
"<?php
示例12: transform
public function transform($comment)
{
return ['id' => $comment->id, "commenter" => ['id' => $comment->commenter->id, 'avatar_url' => $comment->commenter->avatar_url ? $comment->commenter->avatar_url : url('img/user.png'), 'name' => $comment->commenter->name, 'url' => url('profile/' . $comment->commenter->username)], 'product' => ['author' => ['id' => $comment->product->author->id]], 'content' => $comment->content, 'created_at' => time_elapsed_string(strtotime($comment->created_at))];
}
示例13: date_format
Instructor : <b><?php
echo $row['FirstN'] . " " . $row['LastN'];
?>
</b>
</div>
<div class="title">
Message:
</div>
</div>
<div class="time">
<div class="date"><?php
echo date_format($date, "M d, Y");
?>
</div>
<div> <?php
echo time_elapsed_string($row['date']);
?>
</div>
</div>
<div style="padding: 0px 30px 10px;background-color: ">
<?php
echo $row['message'];
?>
</div>
</div>
<br>
<div class="clearfix"></div>
<?php
}
}
示例14: explode
// user's custom message
$message = $obj['data'][$x]['message'];
// picture from the link
$picture = $obj['data'][$x]['picture'];
$picture_url_arr = explode('&url=', $picture);
$picture_url = urldecode($picture_url_arr[1]);
// link posted
$link = $obj['data'][$x]['link'];
// name or title of the link posted
$name = $obj['data'][$x]['name'];
$description = $obj['data'][$x]['description'];
$type = $obj['data'][$x]['type'];
// when it was posted
$created_time = $obj['data'][$x]['created_time'];
$converted_date_time = date('Y-m-d H:i:s', strtotime($created_time));
$ago_value = time_elapsed_string($converted_date_time);
// from
$page_name = $obj['data'][$x]['from']['name'];
// useful for photo
$object_id = $obj['data'][$x]['object_id'];
echo "<div class='row'>";
echo "<div class='col-md-4'>";
echo "<div class='profile-info'>";
echo "<div class='profile-photo'>";
echo "<img src='{$profile_photo_src}' />";
echo "</div>";
echo "<div class='profile-name'>";
echo "<div>";
echo "<a href='https://fb.com/{$fb_page_id}' target='_blank'>{$page_name}</a> ";
echo "shared a ";
if ($type == "status") {
示例15: questions_list
/**
* Returns a simple page.
*
* @return array
* A simple renderable array.
*/
public function questions_list()
{
//Function to get the time ago
function time_elapsed_string($ptime)
{
$etime = time() - $ptime;
if ($etime < 1) {
return '0 seconds';
}
$a = array(365 * 24 * 60 * 60 => 'year', 30 * 24 * 60 * 60 => 'month', 24 * 60 * 60 => 'day', 60 * 60 => 'hour', 60 => 'minute', 1 => 'second');
$a_plural = array('year' => 'years', 'month' => 'months', 'day' => 'days', 'hour' => 'hours', 'minute' => 'minutes', 'second' => 'seconds');
foreach ($a as $secs => $str) {
$d = $etime / $secs;
if ($d >= 1) {
$r = round($d);
return $r . ' ' . ($r > 1 ? $a_plural[$str] : $str) . ' ago';
}
}
}
$config = $this->config('questions.settings');
global $base_url;
$account = \Drupal::currentUser();
$content_array = array();
if ($account->id()) {
$content_array["add_url"] = $base_url . "/node/add/question/";
}
//$questions_count_query = db_query("SELECT `nid` FROM `node` where `type`='". $config->get('content_type') . "'")->fetchAll();
//$que_count = count($questions_count_query);
$questions_count_query = db_query("SELECT node.nid\n\t\tFROM node\n\t\tJOIN node_field_data\n\t\tON node.nid=node_field_data.nid\n\t\tWHERE node.type='" . $config->get('content_type') . "'\n\t\tAND node_field_data.status > 0\n\t\t")->fetchAll();
$que_count = count($questions_count_query);
// $to is the Number of itmes in single page
$to = 10;
if (isset($_GET['page_no']) && $_GET['page_no'] > 0) {
$from = $to * ($_GET['page_no'] - 1);
} else {
$from = 0;
}
//$questions_query = db_query("SELECT `nid` FROM `node` WHERE `type`='". $config->get('content_type') ."' ORDER BY `nid` DESC LIMIT ". $from .",". $to);
//$questions_query = db_query("SELECT `nid` FROM `node` WHERE `type`='". $config->get('content_type') ."' ORDER BY `nid` DESC");
$questions_query = db_query("SELECT node.nid\n\t\tFROM node\n\t\tJOIN node_field_data\n\t\tON node.nid=node_field_data.nid\n\t\tWHERE node.type='" . $config->get('content_type') . "' \n\t\tAND node_field_data.status > 0\n\t\tORDER BY `nid` DESC LIMIT " . $from . "," . $to);
$all_data = $questions_query->fetchAll();
if (count($all_data) > 0) {
foreach ($all_data as $key => $value) {
$node = node_load($value->nid, $reset = FALSE);
$status = $node->status->value;
if ($status > 0) {
$question_title = $node->title->value;
$user_id = $node->uid->target_id;
$submitted_date = date('Y-m-d H:i:s', $node->created->value);
$user = user_load($node->uid->target_id, $reset = FALSE);
$user_name = $user->name->value;
$submitted_time_ago = time_elapsed_string(strtotime($submitted_date));
$ans_cout_query = db_query("SELECT `cid` FROM `comment_field_data` where `pid` IS NULL AND `entity_id`='" . $value->nid . "' AND `status`='1'");
$ans_cout = 0;
foreach ($ans_cout_query as $key1 => $value1) {
$ans_cout++;
}
$content_array["list"][] = array("vote" => 0, "answer" => $ans_cout, "nodeurl" => $base_url . "/node/" . $value->nid, "nodetitle" => $question_title, "answeredbyurl" => $base_url . "/user/" . $user_id, "answeredbyname" => $user_name, "time" => $submitted_time_ago);
}
}
} else {
return drupal_set_message(t("Page not found."), 'error');
}
$round = round($que_count / $to);
$actual = $que_count / $to;
if ($actual > $round) {
$loop_count = $round + 1;
} else {
$loop_count = $round;
}
for ($i = 1; $i <= $loop_count; $i++) {
$pages[] = array("title" => $i, "url" => $base_url . "/questions/?page_no=" . $i);
}
$content_array["pages"] = $pages;
$prev = $_GET['page_no'] - 1;
$next = $_GET['page_no'] + 1;
$content_array["prev"] = $base_url . "/questions/?page_no=" . $prev;
$content_array["next"] = $base_url . "/questions/?page_no=" . $next;
$content_array["current"] = $_GET['page_no'];
$content_array["page_count"] = $loop_count;
// echo "<pre>";
// print_r($content_array);
// exit;
$element['#attached']['library'][] = 'questions/questions-validation';
$element[] = array('#theme' => 'questions_list', '#content' => $content_array);
return $element;
}