• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP timespan函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: show

 public function show($segments)
 {
     extract($_POST);
     if (!isset($username)) {
         $username = $segments[1];
     }
     $entry = DB::query('select id,username,title,location,bio,avatar from users where username = \'' . $username . '\'', 1);
     $entry['activity'] = DB::query('select count(*) as activity from feed where user_id = \'' . $entry['id'] . '\'', 2, 'activity');
     if (!is_file(PATH_UPLOAD . 'profile/' . $entry['avatar'])) {
         $entry['avatar'] = 'default.png';
     }
     $feed = array();
     $feedraw = DB::query('select * from feed where user_id = ' . $entry['id'] . ' and privacy_id = 1 order by id desc limit 20', 0);
     foreach ($feedraw as $i => $row) {
         $feed[$i] = $row;
         $feed[$i]['status'] = Feed::parse_status($row['status']);
         $feed[$i]['files'] = Feed::get_files($row['id'], 'th');
         if (isset($row['created_ts'])) {
             $feed[$i]['timespan'] = timespan($row['created_ts']);
         }
     }
     $follow_btn = "";
     if ($entry['id'] != $_SESSION['user_id']) {
         $following = DB::query('select id from follows where user_id = ' . $_SESSION['user_id'] . ' and user2_id = ' . $entry['id'], 1);
         if ($following) {
             $follow_btn = '<button class="btn btn-success follow" data-id="' . $entry['id'] . '"><i class="ion-checkmark-round"></i> ' . _l('Following') . ' </button>';
         } else {
             $follow_btn = '<button class="btn btn-info follow" data-id="' . $entry['id'] . '"><i class="ion-ios-bolt"></i> ' . _l('Follow') . ' </button>';
         }
     }
     return array('view' => "account", 'follow_btn' => $follow_btn, 'entry' => $entry, 'feed' => $feed);
 }
开发者ID:BobbyBrights,项目名称:social,代码行数:32,代码来源:AccountController.php


示例2: view_forum

 function view_forum($forumID = 0)
 {
     $this->load->helper('date');
     $forumID = intval($forumID);
     $forum = $this->forum_model->getForum($forumID);
     // Check if topic exists
     if (!empty($forum)) {
         $forum['topic_list'] = array();
         // Get a list of posts which have no parents (topics) in this forum
         foreach ($this->post_model->getTopicsInForum($forumID) as $topic) {
             $topic['post_count'] = count($this->post_model->getPostsInTopic($topic['postID']));
             $topic['last_post'] = $this->post_model->getLastPost('topic', $topic['postID']);
             // Convert to unix and see how long ago it was posted
             $timespan = timespan(mysql_to_unix($topic['last_post']['post_date']));
             // If its set and doesnt contain the word days in the timespan
             if (isset($forum['last_post']['post_date']) && !strpos($timespan, 'Day')) {
                 $topic['last_post']['post_date'] = $timespan;
             } else {
                 $topic['last_post']['post_date'] = $topic['last_post']['post_date'];
             }
             $forum['topic_list'][] = $topic;
         }
         $this->data = array_merge($this->data, $forum);
         $this->layout->title('Forums > ' . $this->data['forum_name']);
         $this->layout->create('view_forum', $this->data);
     } else {
         show_error('The Forum doesn\'t exist!');
         $this->layout->create('message', $this->data);
     }
 }
开发者ID:BenneX,项目名称:pyrocms,代码行数:30,代码来源:forums.php


示例3: duration_human

function duration_human($minutes, $output = 'days,hours,minutes', $short = false, $separator = ', ')
{
    $format = function ($value, $unit, $short) {
        $unitString = trans_choice("time.{$unit}", $value);
        return sprintf('<strong>%d</strong>%s', $value, $short ? $unitString[0] : " {$unitString}");
    };
    $strings = [];
    if ($short && $separator == ', ') {
        $separator = ' ';
    }
    $timespan = timespan(time() + $minutes * 60, time(), $output);
    foreach (array_filter($timespan) as $unit => $value) {
        $strings[] = $format($value, $unit, $short);
    }
    if (empty($strings)) {
        end($timespan);
        $unit = key($timespan);
        $strings[] = $format($timespan[$unit], $unit, $short);
    }
    $last = array_pop($strings);
    $count = count($strings);
    if ($count && $short) {
        return sprintf('%s%s%s', implode($separator, $strings), $separator, $last);
    } elseif ($count) {
        return sprintf('%s %s %s', implode($separator, $strings), trans('and'), $last);
    } else {
        return $last;
    }
}
开发者ID:TrackerNetwork,项目名称:DestinyStatus,代码行数:29,代码来源:helpers.php


示例4: index

 function index()
 {
     if (!is_logged()) {
         redirect(base_url());
     }
     $this->data['title'] = lang('off_vote');
     $text = icon('64x64/chart_up.png') . '<p>';
     if (config('alt_vote', 'rf_settings')) {
         $text .= '<br><h2>' . anchor('evote', 'Emudev Top') . '</h2>';
         $text .= '<h2>' . anchor('mmotop', 'MMOTOP') . '</h2>';
     } else {
         if ($this->_get_last_vote() != 0) {
             $text .= lang('off_youvote') . timespan($this->_get_last_vote(true), time()) . ',' . br(1);
             $text .= '<p>' . icon('32x32/clock.png') . lang('off_vote_wait') . timespan(time() + $this->_get_last_vote(), time() + $this->limit) . '</p>';
         } elseif ($this->_last_ip() != 0) {
             $text .= icon("32x32/globe_warning.png") . lang('off_ip_vote');
             $text .= '<p>' . icon('32x32/clock.png') . lang('off_vote_wait') . timespan(time() + $this->_last_ip(), time() + $this->limit) . '</p>';
         } else {
             $text .= lang('off_vote_title') . '</p>' . $this->_show_vote_link() . anchor('vote/getbonus/' . gen_secure(), lang('off_vote_get')) . icon('32x32/note_accept.png');
             // .gen_secure()
         }
     }
     $this->data['content'] = $text . br(2) . icon('32x32/sms.png') . anchor('vote/sms', lang('off_vote_sms'));
     compile();
 }
开发者ID:SelFish131,项目名称:rf_office,代码行数:25,代码来源:vote.php


示例5: GetDateTimeInFormat

 function GetDateTimeInFormat($datestamp, $format)
 {
     switch ($format) {
         // Swatch Internet Time
         case null:
         case 1:
             return date_format(date_create($datestamp), 'jS F, Y') . ' @' . date("B", human_to_unix($datestamp)) . ' .beats';
             // Unix time
         // Unix time
         case 2:
             return human_to_unix($datestamp);
             // Time since
         // Time since
         case 3:
             return timespan(human_to_unix($datestamp), time()) . ' ago';
             // Database
         // Database
         case 4:
             return $datestamp;
             // English
         // English
         case 5:
             return date_format(date_create($datestamp), 'jS F, Y, g:i a');
             // American
         // American
         case 6:
             return date_format(date_create($datestamp), 'F jS, Y, g:i a');
     }
 }
开发者ID:haoji,项目名称:gwl,代码行数:29,代码来源:time.php


示例6: post_comments

 public function post_comments($post_id = 0)
 {
     // load date_helper from CI's app singleton
     get_instance()->load->helper('date');
     $comments = $this->db->where('post_id', (int) $post_id)->order_by('created DESC')->get('comments')->result_array();
     return array_map(function ($a) {
         $a['time_ago'] = timespan(mysql_to_unix($a['created']), time(), 2);
         return $a;
     }, $comments);
 }
开发者ID:DavBfr,项目名称:BlogMVC,代码行数:10,代码来源:posts_model.php


示例7: smart_timestamp

function smart_timestamp($timestamp, $date_format = "j M")
{
    $time = explode(',', timespan($timestamp));
    $seconds_day = 86400;
    if (now() - $timestamp > $seconds_day) {
        return date($date_format, $timestamp);
    } else {
        return $time[0] . " ago";
    }
}
开发者ID:netspencer,项目名称:Naplog,代码行数:10,代码来源:naplog_helper.php


示例8: index

 public function index($name)
 {
     $fsdata = dirname(__FILE__) . '/../../data/' . $name;
     $filelist = Utils::fileList($fsdata, 5);
     $files = array();
     foreach ($filelist as $file) {
         $ts2 = strtok($file, ".");
         $mins = (time() - filename2date($ts2, 'U')) / 60;
         $unixtime = filename2date($ts2, $mins > 1440 ? 'Y M j D H:i' : 'D H:i');
         $files[] = array('filename' => $file, 'ts' => date2es($unixtime) . ' (hace ' . timespan($mins) . ')');
     }
     return array('name' => $name, 'files' => $files);
 }
开发者ID:BobbyBrights,项目名称:social,代码行数:13,代码来源:cam.php


示例9: token_time

 function token_time($access_token, $time)
 {
     $access_token_info = $this->general->custom_file_get_contents('https://graph.facebook.com/oauth/access_token_info?client_id=' . $this->app_id . '&access_token=' . $access_token);
     $access_token_info = json_decode($access_token_info);
     if (isset($access_token_info->access_token) && isset($access_token_info->expires_in)) {
         return timespan($time - $access_token_info->expires_in, $time);
     } else {
         if (isset($access_token_info->access_token) && !isset($access_token_info->expires_in)) {
             return LNG_TOKEN_NOT_EXPIRE;
         } else {
             return LNG_TOKEN_NOT_EXPIRE_TIME;
         }
     }
 }
开发者ID:masterpowers,项目名称:autoposter,代码行数:14,代码来源:faceboook.php


示例10: show

    public function show($segments)
    {
        $entry = array();
        $data = DB::query('select webcams.title, webcams.caption, webcams.code, webcams.location, users.username, users.title as user_title
			from webcams 
			join users on users.id = webcams.user_id 
			where webcams.code = \'' . $segments[1] . '\'', 1);
        if ($data) {
            $files = File::dir_content(PATH_WEBCAM . $data['username'], '', 'lastsnap.jpg');
            $dotssize = 16;
            $dotssize = count($files);
            $select = array();
            if (count($files)) {
                sort($files);
                foreach ($files as $i => $file) {
                    $tmp = stat(PATH_WEBCAM . $data['username'] . '/' . $file);
                    if (isset($segments[2]) && isset($segments[3])) {
                        if ($tmp[9] >= $segments[2] && $tmp[9] <= $segments[3]) {
                            //$select[] = array($tmp[9],date('Y m d H:i:s',$tmp[9]),timespan($tmp[9]));
                        } else {
                            unset($files[$i]);
                        }
                    } else {
                        if ($i == count($files) - 1) {
                            $segments[3] = $tmp[9];
                        }
                    }
                    $select[] = array($tmp[9], date('Y m d H:i:s', $tmp[9]), timespan($tmp[9]));
                }
                if ($segments[4] == null) {
                    $segments[4] = 1000;
                }
                if ($segments[5] == null) {
                    $segments[5] = 500;
                }
                $stat = stat(PATH_WEBCAM . $data['username'] . '/' . $files[count($files) - 1]);
                $entry = $data;
                $entry['count'] = count($files);
                $entry['timespan'] = timespan($stat[9]);
                //$entry['files'] = array_slice($files,count($files)-$dotssize,count($files));
                $entry['files'] = $files;
            }
        }
        return array('view' => 'webcams/show', 'select' => $select, 'segments' => $segments, 'entry' => $entry);
    }
开发者ID:BobbyBrights,项目名称:social,代码行数:45,代码来源:WebcamsController.php


示例11: index

 function index()
 {
     $this->data['title'] = lang('off_acc') . gen_name_profile();
     $this->data['content'] = '<p>' . lang('off_welcome') . gen_name_profile() . lang('off_welcome2') . '</p>';
     if (check_master_answer() == false) {
         $this->data['content'] .= icon('32x32/security.png') . anchor('main/profile', b(lang('off_attepprofile')));
     }
     $this->data['content'] .= br(2) . '<p>' . effect_toggle(b(lang('off_main_lastbuy')), 'log', 'slide') . '</p>
     <hr>' . hiddendiv("log", GetLogBuy()) . $this->_reflink();
     //$this->data['content'].=anchor('rdonate',icon('24x24/euro_currency_sign.png').lang('off_return_donate')).br(1);
     if (is_gm()) {
         $this->data['content'] .= lang('off_gm_panel') . anchor('manager', lang('off_gm_btn2'));
     }
     if (prenium_active() == true) {
         $this->data['content'] .= icon('32x32/package_download.png', lang('off_premhave')) . lang('off_premium_expire') . timespan(time(), premium_expire());
     }
     compile();
 }
开发者ID:SelFish131,项目名称:rf_office,代码行数:18,代码来源:main.php


示例12: index

 public function index()
 {
     // Define the page title.
     $data['title'] = lang('tle_recent_discussions');
     // Define the template.
     $data['template'] = 'pages/home/home';
     // Get the discussions from the database.
     $discussions = $this->discussions->order_by(array('sticky' => 'DESC', 'posted' => 'DESC'))->get_all();
     // Set the table template.
     $data['tmpl'] = array('table_open' => '<table class="table table-hover">');
     $this->table->set_template(element('tmpl', $data));
     // Set the table headings.
     $this->table->set_heading('', 'Discussion', 'Users', 'Replies', 'Views', 'Activity');
     // Loop through the discussions.
     if (!empty($discussions)) {
         foreach ($discussions as $row) {
             // Get the user who created the discussion.
             $poster = $this->users->get_by('username', $row->poster);
             $last_poster = $this->users->get_by('username', $row->last_poster);
             // Build the posters avatar.
             $data['avatar'] = array('src' => $this->gravatar->get_gravatar($poster->email, $this->config->item('gravatar_rating'), $this->config->item('gravatar_size'), $this->config->item('gravatar_default_image')), 'title' => '' . $poster->username . ' - Discussion Creator');
             // Get the category associated with the discussion.
             $cat = $this->categories->get_by('id', $row->category_id);
             if (!empty($this->_unread)) {
                 if (in_array($row->id, $this->_unread)) {
                     $unread = true;
                 } else {
                     $unread = false;
                 }
             } else {
                 $unread = false;
             }
             $data['discussions'][] = array('subject' => $unread == TRUE ? anchor(site_url('discussions/view/' . $row->id), '<i class="fa fa-lightbulb-o"></i>&nbsp;<strong>' . $row->subject . '</strong>') : anchor(site_url('discussions/view/' . $row->id), $row->subject), 'replies' => $row->replies, 'views' => $row->views, 'last_comment' => timespan($row->last_comment, time()), 'last_poster' => anchor(site_url('users/profile/' . $row->last_poster_id), $row->last_poster), 'category' => anchor(site_url('categories/' . $cat->slug . ''), $cat->name), 'avatar' => anchor(site_url('users/profile/' . $poster->id), img(element('avatar', $data))), 'avatar_last_poster' => anchor(site_url('users/profile/' . $last_poster->id), img(element('avatar_last_poster', $data))), 'sticky' => $row->sticky == 1 ? '<span class="label label-success"><i class="fa fa-thumb-tack"></i></span>&nbsp;' : '', 'closed' => $row->closed == 1 ? '<span class="label label-danger"><i class="fa fa-lock"></i></span>&nbsp;' : '', 'unread' => in_array($row->id, $this->_unread) ? 'unread' : '');
         }
     } else {
         // Fill with blank data to prevent errors.
         $data['discussions'] = '';
     }
     // Build the page breadcrumbs.
     $this->crumbs->add(lang('crumb_recent_discussions'));
     // Define the page data.
     $data['page'] = array('btn_new_discussion' => anchor(site_url('discussions/new_discussion'), lang('btn_new_discussion'), array('class' => 'btn btn-default btn-xs')), 'lnk_mark_all' => anchor(site_url('discussions/mark_all'), lang('lnk_mark_all')), 'discussions' => element('discussions', $data), 'has_discussions' => !empty($discussions) ? 1 : 0, 'breadcrumbs' => $this->crumbs->output(), 'pagination' => $this->pagination->create_links());
     $this->render(element('page', $data), element('title', $data), element('template', $data));
 }
开发者ID:RvstFyth,项目名称:DoveForums,代码行数:44,代码来源:Forums.php


示例13: feed

 /**
  * Load a constant
  *
  * Magic method to get a constant or global variable
  * 
  * Usage:
  *   {{ twitter:feed username="twitterusername" limit="5" }}
  * 
  * @return array The tweet objects in an array.
  */
 function feed()
 {
     $username = $this->attribute('username');
     $limit = $this->attribute('limit', 5);
     if (!($tweets = $this->pyrocache->get('twitter-' . $username))) {
         $tweets = json_decode(@file_get_contents($this->feed_url . '&screen_name=' . $username . '&count=' . $limit));
         $this->pyrocache->write($tweets, 'twitter-' . $username, $this->settings->twitter_cache);
     }
     $patterns = array('((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\\w\\d:#@%/;$()~_?\\+-=\\\\.&]*)' => '<a href="$0" target="_blank">$0</a>', '|([a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,6})|i' => '<a href="mailto:$1">$1</a>', '| @([a-z0-9-_]+)|i' => '<a href="http://twitter.com/$1" target="_blank">$0</a>', '|#([a-z0-9-_]+)|i' => '<a href="http://twitter.com/search?q=%23$1" target="_blank">$0</a>');
     if (!$tweets) {
         return array();
     }
     foreach ($tweets as &$tweet) {
         $tweet->id = sprintf('%.0f', $tweet->id);
         $tweet->text = str_replace($username . ': ', '', $tweet->text);
         $tweet->text = preg_replace(array_keys($patterns), $patterns, $tweet->text);
         $tweet->timespan = strtolower(current(explode(',', timespan(strtotime($tweet->created_at))))) . ' ago';
     }
     return $tweets;
 }
开发者ID:namdum,项目名称:pyrocms,代码行数:30,代码来源:twitter.php


示例14: nicetime

function nicetime($timestamp)
{
    if ($timestamp == '' or !is_numeric($timestamp)) {
        return '';
    }
    $hari = date('l', $timestamp);
    $tgl = date('d', $timestamp);
    $bln = date('F', $timestamp);
    $thn = date('Y', $timestamp);
    $pukul = date('H:i', $timestamp);
    // timespan dari CI's date helper
    $timespan = strtolower(timespan($timestamp));
    $timespan = str_replace(',', '', $timespan);
    $exp = explode(' ', $timespan);
    $k = $exp[1];
    $v = $exp[0];
    if ($v > 0) {
        if (stristr($k, 'year') or date('Y') > $thn) {
            return $tgl . ' ' . $bln . ' ' . $thn;
        } elseif (stristr($k, 'week') or stristr($k, 'month')) {
            return $tgl . ' ' . $bln . ' at ' . $pukul;
        } elseif (stristr($k, 'day') or stristr($k, 'hour') or stristr($k, 'minute') or stristr($k, 'second')) {
            if ($v >= 2 and stristr($k, 'day')) {
                return $hari . ' at ' . $pukul;
            } elseif (date('j') - date('j', $timestamp) == 1) {
                return 'Yesterday at ' . $pukul;
            } elseif (date('D') == date('D', $timestamp) and ($v >= 10 and stristr($k, 'hour'))) {
                return 'Today at ' . $pukul;
            } elseif (stristr($k, 'hour') and $v < 10 or stristr($k, 'minute') or stristr($k, 'second')) {
                if (stristr($k, 'second') and $v <= 15) {
                    return 'just now';
                }
                return $v . ' ' . $k . ' ago';
            } else {
                return $hari . ' at ' . $pukul;
            }
        }
    } else {
        return 'just now';
    }
}
开发者ID:ericariyanto,项目名称:eofficecms,代码行数:41,代码来源:npaperbox_helper.php


示例15: get_logged_actions

/**
 * Get an array containing logged actions.
 * 
 * If $action is left empty but $item_id is not, or if the $action is an integer,
 * it retrieves all the actions pertaining to $item_id.
 * 
 * If $action is NOT empty but $item_id is, it retrieves all the $action actions in the DB.
 * 
 * If both $action and $item_id have a value, it returns all $action actions pertaining to $item_id.
 * 
 * Returns an array. Triggers an error if the action does not exist in My_lang.
 * 
 * Usage:
 * 
 * 
 * @staticvar array $userIdCache
 * @param string|integer $action
 * @param integer $item_id
 * @return array 
 */
function get_logged_actions($action = '', $item_id = 0)
{
    # In order to increase performance, whenever the function gets the username
    # of a given user_id, it'll cache it, so that it won't need to go query the DB
    # again for the duration of the request.
    static $userIdCache = array();
    if (!empty($action) and !is_int($action) and !lang($action)) {
        trigger_error('Action message does not exist for ' . $action . '. Create it in /language/My_lang.php.');
    }
    $CI =& get_instance();
    $CI->load->model('users/user_m');
    $where = array();
    if (!empty($item_id)) {
        $where['item_id'] = $item_id;
    }
    if (is_int($action)) {
        $where['item_id'] = $action;
    } elseif (!empty($action)) {
        $where['action'] = $action;
    }
    $buffer = $CI->db->get_where('action_logs', $where)->result_array();
    foreach ($buffer as $key => $row) {
        $variables = array('timeago' => strtolower(timespan($row['timestamp']) . ' ago'));
        if ($row['user_id'] != 0) {
            if (!isset($userIdCache[$row['user_id']])) {
                $userBuffer = $CI->user_m->select('username')->get($row['user_id']);
                $userBuffer = $userBuffer->username;
            } else {
                $userBuffer = $userIdCache[$row['user_id']];
            }
            $variables['username'] = $userBuffer;
        }
        if ($row['item_id'] != 0) {
            $variables['item_id'] = $row['item_id'];
        }
        foreach ($variables as $variable => $value) {
            $buffer[$key]['message'] = str_ireplace('{' . $variable . '}', $value, $buffer[$key]['message']);
        }
    }
    return $buffer;
}
开发者ID:kulgee001,项目名称:yggdrasil,代码行数:61,代码来源:app_logger_helper.php


示例16: time_ago

function time_ago($timeago, $short = false)
{
    $instance =& get_instance();
    $now = time();
    $timepices = array();
    if (!is_numeric($timeago)) {
        $timeago = human_to_unix($timeago);
    }
    $timespan = timespan($timeago, $now);
    $timespan = explode(",", trim($timespan));
    foreach ($timespan as $key => $value) {
        $timespanvalue = explode(" ", trim($value));
        $arrayvalue = $timespanvalue[0] . " " . $instance->lang->line('application_' . $timespanvalue[1]);
        $timepices[$key] = $arrayvalue;
    }
    $return = $timepices[0];
    if (isset($timepices[1]) && $short == false) {
        $return .= ' ' . $instance->lang->line('application_and') . ' ' . $timepices[1];
    }
    $return .= ' ' . $instance->lang->line('application_ago');
    return $return;
}
开发者ID:imranweb7,项目名称:msitc-erp,代码行数:22,代码来源:timeago_helper.php


示例17: test

 function test()
 {
     ini_set('date.timezone', 'PRC');
     //people republic of china
     $this->load->helper("date");
     //  echo timezone_menu("UP8");
     // $datestring = "Year: %Y Month: %m Day: %d - %h:%i %a";
     $time = time();
     // echo standard_date("DATE_ATOM", $time);
     $timestamp = local_to_gmt($time);
     //转化为时间戳 gmt greenwich mean time 格林尼治时间
     //$timezone="PRC";//people republic of china
     //  echo gmt_to_local($timestamp,$timezone,true);
     $mysql = '20061124092345';
     $unix = mysql_to_unix($mysql);
     $past_time = '19900926092633';
     $a = strtotime($past_time);
     echo local_to_gmt($past_time);
     // $time=time();
     echo timespan($past_time, $time);
     ///$past_time 一定是个时间戳
 }
开发者ID:GStepOne,项目名称:CI,代码行数:22,代码来源:time.php


示例18: index

	function index()
	{
		$this->check_session();
		$this->load->model('Workout', 'workout');
		$user->id = $this->tank_auth->get_user_id();
		$result['workouts'] = $this->workout->get_connection_workouts($user);


		for($i=0; $i<count($result['workouts']); $i++)
		{
			$post_time = $result['workouts'][$i]->workout_date;
			
			$post_date = human_to_unix($post_time);
			$post_date = timespan($post_date);
			
			$post_time_array = explode(", ", $post_date);
			$post_time_count = count($post_time_array);
			switch ($post_time_count) 
			{
			    case 0:
			        break;
			    case 1:
			        $post_date = strtolower($post_time_array[0])." ago";
			        break;
			    case 2:
			    	$post_date = strtolower($post_time_array[1])." ago";
			        break;
			    case 3:
			    	$post_date = strtolower($post_time_array[2])." ago";
			        break;
			    default:
					$post_date = date("j \of M y", strtotime($post_time));
			}
			$result['workouts'][$i]->workout_date = $post_date;
		}

		$this->load->view('connections', $result);
	}
开发者ID:njhamann,项目名称:FitPursue,代码行数:38,代码来源:connections.php


示例19: calculate_hours

 public function calculate_hours($time_in, $time_out, $timein_date, $timeout_date)
 {
     // Extract timed in && out
     $time_in = self::time_extract($time_in);
     $time_out = self::time_extract($time_out);
     // Extract date timed in && out
     $timedin_date = self::date_extract($timein_date);
     $timedout_date = self::date_extract($timeout_date);
     // Convert to military time
     $timedin_hour = self::to_military($time_in['hour'], $time_in['ampm']);
     $timedout_hour = self::to_military($time_out['hour'], $time_out['ampm']);
     // Calculate span of time ( Excluding minutes yet )
     $start = mktime($timedin_hour, 0, 0, $timedin_date['month'], $timedin_date['day'], $timedin_date['year']);
     $end = mktime($timedout_hour, 0, 0, $timedout_date['month'], $timedout_date['day'], $timedout_date['year']);
     // Calculate minutes
     $total_minutes = intval($time_in['minute']) + intval($time_out['minute']);
     // Now get the hours rendered
     $timespan = timespan($start, $end, 5);
     $timespan = explode(',', $timespan);
     $found = false;
     foreach ($timespan as $time) {
         $time = trim($time);
         if (strpos($time, 'Hour') !== false) {
             $found = true;
             $hours = explode(' ', $time);
         }
     }
     if ($found) {
         $hours_rendered = (int) $hours[0];
     } else {
         $hours_rendered = 0;
     }
     if ($total_minutes > 59) {
         $hours_rendered = $hours_rendered + 1;
     }
     return $hours_rendered;
 }
开发者ID:jhernani,项目名称:chu,代码行数:37,代码来源:E_attendance.php


示例20: list_items

 function list_items($id, $person, $source, $place_id, $place_name, $message = null, $img, $cords, $time)
 {
     $map_item['id'] = $id;
     $map_item['person'] = $person;
     $map_item['source'] = $source;
     $map_item['place_id'] = $place_id;
     $map_item['place_name'] = $place_name;
     $map_item['message'] = $message;
     $map_item['img'] = $img;
     $map_item['cords'] = $cords;
     $map_item['time'] = timespan($time) . " ago";
     $map_item['time_raw'] = $time;
     $this->map_items[] = $map_item;
 }
开发者ID:netspencer,项目名称:friendsonamap,代码行数:14,代码来源:map_model.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP timestamp函数代码示例发布时间:2022-05-23
下一篇:
PHP times函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap