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


PHP timeDiff函数代码示例

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


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

示例1: indexAction

 function indexAction()
 {
     if (POST) {
         set_time_limit(999999);
         $emails = $users = array();
         $emailRaw = $this->user->ImportContacts($_POST['of'], $_POST["n"], $_POST["p"]);
         foreach ($emailRaw["out"] as $k => $v) {
             if ($this->user->CheckEmail($v[0])) {
                 $usr = $this->user->GetDetailsByEmail($v[0]);
                 $usrNam = strlen($usr["fname"] . $usr["lname"]) < 10 ? $usr["fname"] . " " . $usr["lname"] : (strlen($usr["fname"]) < 10 ? $usr["fname"] : substr($usr["fname"], 0, 10) . '..');
                 $users[] = array(encode($usr["id"]), $usr["image"], $usrNam, ($usr["gender"] == "M" ? "Male" : "Female") . ", " . timeDiff(strtotime($usr["birthDay"]), array('parts' => 1, 'precision' => 'year', 'separator' => '', 'next' => '')));
             } else {
                 $eM = array("n" => $k, "i" => encode($v[1]));
                 if (strpos($v[0], "@")) {
                     $eM = array_merge($eM, array("e" => $v[0]));
                 }
                 if ($v[2] > 0) {
                     $eM = array_merge($eM, array("m" => $v[2]));
                 }
                 $emails[] = $eM;
             }
         }
         die(json_encode(array("emails" => $emails, "users" => $users, "m" => count($emails) > 0 ? "You got " . count($emails) . " contacts from your " . $_POST["of"] . " id." : "<strong>No contacts found.</strong><br />May be your login are invalid.", "mT" => count($emails) > 0 ? "yeppe" : "")));
     }
     $this->view->outContacts = $this->user->outContacts();
     $this->view->inContacts = $this->user->inContacts();
 }
开发者ID:gauravstomar,项目名称:Pepool,代码行数:27,代码来源:InviteController.php

示例2: energizingAction

    function energizingAction()
    {
        $user = new UsersModel();
        $this->session->from = $this->session->from > 0 ? $this->session->from + 1 : 30;
        $users = $user->Search(array(), array($this->session->from, 1), NULL, array("gender DESC"));
        ?>
        <?php 
        $i = 0;
        foreach ($users as $r) {
            ?>
            <a href="<?php 
            echo WWW_ROOT;
            ?>
user/<?php 
            echo encode($r["id"]);
            ?>
"><img src="<?php 
            echo IMAGES;
            ?>
user/icon/<?php 
            echo $r["image"];
            ?>
" /><span><?php 
            echo strlen($r["username"]) < 10 ? $r["username"] : substr($r["username"], 0, 10) . '..';
            ?>
<br /><em><?php 
            echo str_replace(" years", ", ", timeDiff(strtotime($r["birthDay"]), array('parts' => 1, 'precision' => 'year', 'separator' => '', 'next' => ''))) . ($r["gender"] == 'M' ? 'Male' : 'Female') . ($r["city"] ? "<br />" . $r["city"] : "");
            ?>
</em></span></a>
        <?php 
        }
        die;
    }
开发者ID:gauravstomar,项目名称:Pepool,代码行数:33,代码来源:IndexController.php

示例3: email_login

function email_login($email, $password)
{
    $CI =& get_instance();
    $user = new User();
    $user->where(array('email' => $email, 'password' => $password))->get();
    if ($user->exists()) {
        if ($user->profile->type == "ประชาชนทั่วไป") {
            $timediff = timeDiff($user->last_login, date("Y-m-d H:i:s", now()));
            $webboard_status_config = new Webboard_status_config(1);
            if ($timediff > $webboard_status_config->memlock) {
                $user->m_status = "ban";
                $user->last_login = $user->last_login;
            } else {
                $user->m_status = "active";
                $user->last_login = date("Y-m-d H:i:s", now());
            }
        }
        $user->save();
        if ($user->m_status == "ban") {
            return FALSE;
        }
        $_SESSION['id'] = $user->id;
        // $CI->session->set_userdata('id',$user->id);
        $_SESSION['level'] = $user->level_id;
        // $CI->session->set_userdata('level',$user->level_id);
        //$log = fopen("log.txt", "a");
        //fwrite($log, ' '.$user->last_login.' - '.$user->email.' เข้าสู่ระบบ'.'\r\n');
        //fclose($log);
        file_put_contents('log.txt', $user->last_login . ' - ' . $user->email . ' เข้าสู่ระบบ' . "\n", FILE_APPEND);
        return TRUE;
    } else {
        return FALSE;
    }
}
开发者ID:unisexx,项目名称:thaigcd2015,代码行数:34,代码来源:auth_helper.php

示例4: dateAddTime

function dateAddTime($date, $time)
{
    $start = explode(" ", $date);
    $timeDiff = timeDiff($start[1], $time, "+");
    $diffArray = explode(":", $timeDiff);
    //>24?
    if ($diffArray[0] >= 24) {
        $diffArray[0] -= 24;
        $diffArray[0] = str_pad($diffArray[0], 2, "0", STR_PAD_LEFT);
        $start[0] = date("Y-m-d", strtotime($start[0] . " +1 day"));
    }
    return $start[0] . " " . implode(":", $diffArray);
}
开发者ID:flafuente,项目名称:parrillas,代码行数:13,代码来源:functions.php

示例5: getAction

 function getAction()
 {
     if (!$this->getRequest()->getParam('html')) {
         $uTw = array();
         $tweet = $this->tweet->Get($_REQUEST['limit'], $this->getRequest()->getParam('of') ? decode($this->getRequest()->getParam('of')) : NULL, $_REQUEST['limit'] == 1 ? 'DESC' : 'ASC');
         if ($tweet) {
             foreach ($tweet as $uT) {
                 $uT["timestamps"] = timeDiff(strtotime($uT["timestamps"]));
                 $uT["id"] = encode($uT["id"]);
                 $uT["uid"] = encode($uT["uid"]);
                 $uTw[] = $uT;
             }
         }
         jencode($uTw);
         die;
     }
 }
开发者ID:gauravstomar,项目名称:Pepool,代码行数:17,代码来源:TweetController.php

示例6: displayStats

function displayStats($pid)
{
    if ($pid == 0) {
        return;
    }
    $ret = "";
    $mod = getModId($_GET[mod]);
    $map = getMapId($_GET[map]);
    $total = mysql_result(mysql_query("SELECT count(*) FROM Games2players WHERE playerId = {$pid} AND spectator=0"), 0, 0);
    $wins = mysql_result(mysql_query("SELECT count(*) FROM Games2players WHERE playerId = {$pid} AND spectator=0 AND victoryTeam=1 AND aliveTillEnd=1"), 0, 0);
    $quit = mysql_result(mysql_query("SELECT count(*) FROM Games2players WHERE playerId = {$pid} AND spectator=0 AND (dropTime<>0 OR leaveTime<>0) AND (dropTime < loseTime OR leaveTime < loseTime)"), 0, 0);
    $maptime = mysql_result(mysql_query("SELECT sum(duration) FROM Games WHERE mapId = {$map} AND id IN (SELECT distinct gameId FROM Games2players WHERE playerId={$pid})"), 0, 0);
    $modtime = mysql_result(mysql_query("SELECT sum(duration) FROM Games WHERE modId = {$mod} AND id IN (SELECT distinct gameId FROM Games2players WHERE playerId={$pid})"), 0, 0);
    $side = @mysql_result(mysql_query("SELECT side,count(*) AS cnt FROM Games2players WHERE playerId={$pid} AND spectator=0 GROUP BY side ORDER BY cnt DESC LIMIT 0,1"), 0, 0);
    @($ret = "total:{$total} games, skill rating:" . eloToText($pid) . " (" . round(getPlayerElo($pid)) . "), won:" . round(100 * $wins / $total) . "%, left:" . round(100 * $quit / $total) . "%, maptime:" . timeDiff($maptime) . ", modtime:" . timeDiff($modtime) . ", side:{$side}\n");
    return $ret;
}
开发者ID:TurBoss,项目名称:Zero-K-Infrastructure,代码行数:17,代码来源:stats.php

示例7: displaySmurf

function displaySmurf($id)
{
    $ret = "";
    $res = mysql_query("SELECT name, lastSeen, rank FROM Players AS p JOIN Players2ip AS i ON p.id = i.playerId WHERE ip IN (SELECT ip FROM Players2ip WHERE playerId={$id}) GROUP BY playerId ORDER BY name");
    $cnt = 0;
    while ($row = mysql_fetch_array($res)) {
        if ($row[rank] == 0) {
            $row[rank] = "?";
        }
        if ($cnt > 0) {
            $ret .= ", ";
        }
        $ret .= $row[name] . " (r:{$row['rank']}, " . timeDiff(time() - $row[lastSeen]) . ")";
        $cnt++;
    }
    return $ret;
}
开发者ID:TurBoss,项目名称:Zero-K-Infrastructure,代码行数:17,代码来源:smurfs.php

示例8: _save

 private function _save($ot_id = 0)
 {
     $this->load->library("WorkflowSystem");
     if ($_POST) {
         $post = $this->input->post(NULL, TRUE);
         $ot_date = $post['input_ot_date'];
         $ot_time_from = $post['input_ot_time_from'];
         $ot_time_to = $post['input_ot_time_to'];
         $ot_remark = $post['input_ot_remark'];
         $data = array();
         $data['wot_date'] = dbDateFormatFromThaiUn543($ot_date);
         $data['wot_time_from'] = $ot_time_from;
         $data['wot_time_to'] = $ot_time_to;
         $data["wot_remark"] = $ot_remark;
         $data['wot_request_hour'] = timeDiff($ot_time_from, $ot_time_to);
         $data['wot_request_by'] = $this->user_id;
         $data['wot_workflow_id'] = $this->workflow_start_id;
         $data['wot_status_id'] = 1;
         if ($ot_id === 0) {
             $data['wot_request_date'] = getDateTimeNow();
             $ot_id = $this->ot->insert($data);
             insert_log_ot($ot_id, 'add', 'ส่งใบคำขอทำงานล่วงเวลา');
             $this->workflowsystem->set_require_data($ot_id, "overtime", "request");
         } else {
             $data['wot_latest_update'] = getDateTimeNow();
             $where = array("wot_id" => $ot_id);
             $affected = $this->ot->update($data, $where);
             insert_log_ot($ot_id, 'edit', 'แก้ไขใบคำขอทำงานล่วงเวลา');
             $this->workflowsystem->set_require_data($ot_id, "overtime", "editrequest");
         }
         //run workflow
         $process = $this->workflowsystem->run();
         //alert after all process
         if ($ot_id > 0 && $process == 'success') {
             echo swalc("บันทึกเรียบร้อย", '', 'success', 'window.location.href = "' . site_url('Overtime') . '"');
         } else {
             if ($ot_id > 0 && $process != 'success') {
                 echo swalc("บันทึกเรียบร้อย", 'แต่ไม่สามารถส่งอีเมล์ได้', 'warning', 'window.location.href = "' . site_url('Overtime') . '"');
             } else {
                 echo swalc("ผิดพลาด กรุณาลองใหม่ภายหลัง", '', 'error', 'window.location.href = "' . site_url('Overtime') . '"');
             }
         }
     }
 }
开发者ID:KanexKane,项目名称:hrsystem,代码行数:44,代码来源:Overtime.php

示例9: _home

	public function _home() {
		global $config, $user, $cache;

		$username = request_var('username', '');
		$ip = request_var('ip', '');

		if (_button() && ($username || $ip)) {
			if ($username) {
				$username_base = get_username_base($username);

				$sql = 'SELECT m.username, l.*
					FROM _members m, _members_iplog l
					WHERE m.user_id = l.log_user_id
						AND m.username_base = ?
					ORDER BY l.log_time DESC';
				$sql = sql_filter($sql, $username_base);
			} else if ($ip) {
				$sql = 'SELECT m.username, l.*
					FROM _members m, _members_iplog l
					WHERE m.user_id = l.log_user_id
						AND l.log_ip = ?
					ORDER BY l.log_time DESC';
				$sql = sql_filter($sql, $ip);
			}
			$result = sql_rowset($sql);

			foreach ($result as $i => $row) {
				if (!$i) _style('log');

				_style('log.row', array(
					'UID' => $row['log_user_id'],
					'USERNAME' => $row['username'],
					'TIME' => $user->format_date($row['log_time']),
					'ENDTIME' => (($row['log_endtime']) ? $user->format_date($row['log_endtime']) : '&nbsp;'),
					'DIFFTIME' => (($row['log_endtime']) ? _implode(' ', timeDiff($row['log_endtime'], $row['log_time'], true, 1)) : '&nbsp;'),
					'IP' => $row['log_ip'],
					'AGENT' => $row['log_agent'])
				);
			}
		}

		return;
	}
开发者ID:nopticon,项目名称:rockr,代码行数:43,代码来源:user_ip_report.php

示例10: getAction

 function getAction()
 {
     if (!$this->getRequest()->getParam('html')) {
         $uTw = array();
         $pics = $this->pics->Get($_REQUEST['limit'], $this->getRequest()->getParam('of') ? decode($this->getRequest()->getParam('of')) : NULL, $_REQUEST['limit'] == 1 ? 'DESC' : 'ASC');
         if ($pics) {
             foreach ($pics as $uT) {
                 $uT["timestamps"] = timeDiff(strtotime($uT["timestamps"]));
                 $uT["W"] = $uT["width"];
                 unset($uT["width"]);
                 $uT["H"] = $uT["height"];
                 unset($uT["height"]);
                 $uT["id"] = encode($uT["id"]);
                 $uT["uid"] = encode($uT["uid"]);
                 $uTw[] = $uT;
             }
         }
         jencode($uTw);
         die;
     }
 }
开发者ID:gauravstomar,项目名称:Pepool,代码行数:21,代码来源:PhotosController.php

示例11: BanCheck

 function BanCheck($ip, $board = '', $force_display = false)
 {
     global $tc_db;
     if (!isset($_COOKIE['tc_previousip'])) {
         $_COOKIE['tc_previousip'] = '';
     }
     $bans = array();
     $results = $tc_db->GetAll("SELECT * FROM `" . KU_DBPREFIX . "banlist` WHERE ((`type` = '0' AND ( `ipmd5` = '" . md5($ip) . "' OR `ipmd5` = '" . md5($_COOKIE['tc_previousip']) . "' )) OR `type` = '1') AND (`expired` = 0)");
     if (count($results) > 0) {
         foreach ($results as $line) {
             if ($line['type'] == 1 && strpos($ip, md5_decrypt($line['ip'], KU_RANDOMSEED)) === 0 || $line['type'] == 0) {
                 if ($line['until'] != 0 && $line['until'] < time()) {
                     $tc_db->Execute("UPDATE `" . KU_DBPREFIX . "banlist` SET `expired` = 1 WHERE `id` = " . $line['id']);
                     $line['expired'] = 1;
                     $this->UpdateHtaccess();
                 }
                 if ($line['globalban'] != 1) {
                     if (in_array($board, explode('|', $line['boards'])) || $board == '') {
                         $line['appealin'] = substr(timeDiff($line['appealat'], true, 2), 0, -1);
                         $bans[] = $line;
                     }
                 } else {
                     $line['appealin'] = substr(timeDiff($line['appealat'], true, 2), 0, -1);
                     $bans[] = $line;
                 }
             }
         }
     }
     if (count($bans) > 0) {
         $tc_db->Execute("END TRANSACTION");
         echo $this->DisplayBannedMessage($bans);
         die;
     }
     if ($force_display) {
         /* Instructed to display a page whether banned or not, so we will inform them today is their rucky day */
         echo '<title>' . _gettext('YOU ARE NOT BANNED!') . '</title><div align="center"><img src="' . KU_WEBFOLDER . 'youarenotbanned.jpg"><br /><br />' . _gettext('Unable to find record of your IP being banned.') . '</div>';
     } else {
         return true;
     }
 }
开发者ID:stormeus,项目名称:Kusaba-Z,代码行数:40,代码来源:bans.class.php

示例12: getAction

 function getAction()
 {
     $scrap = $this->scrap->Get();
     $uTw = array();
     if ($scrap) {
         $recivedBy = $this->scrap->uid;
         foreach ($scrap as $uT) {
             $uT["timestamps"] = timeDiff(strtotime($uT["timestamps"]));
             $postedBy = $uT["uid"];
             $uT["id"] = encode($uT["id"]);
             $uT["uid"] = encode($uT["uid"]);
             $uT["scrap"] = str($uT["scrap"]);
             $uT["r"] = $recivedBy == $this->session->user['id'];
             $uT["d"] = $postedBy == $this->session->user['id'] || $recivedBy == $this->session->user['id'];
             if ($uT["d"] || $uT["privacy"] == 'N') {
                 $uTw[] = $uT;
             }
         }
         jencode($uTw);
     }
     die;
 }
开发者ID:gauravstomar,项目名称:Pepool,代码行数:22,代码来源:ScrapController.php

示例13: loader_image_delete

				<?php 
    //endif;
    ?>
				<?php 
    if ($id_user == getAccountUserId() or $subitem->comment_by == getAccountUserId()) {
        echo loader_image_delete("class='deleteItem' onclick='callFuncDeleteComment({$subitem->id_photo_comment});'");
    }
    ?>
			</div>
			<div class="comment">
				<?php 
    echo maintainHtmlBreakLine($subitem->comment);
    ?>
			</div>
			<p class="time"><?php 
    echo timeDiff($subitem->add_date);
    ?>
</p>
		</div>
	</div>
	<div class="clear"></div>
<?php 
}
?>

<div class="clear"></div>
			
<div class="article-response">
	
	<div class="article-response-form" id="commentSectionSubmitDiv">
		<p>
开发者ID:phonglanpls,项目名称:jz-proj-2012,代码行数:31,代码来源:show_comments.php

示例14: explode

// log_error("start $start, end $end, archivestart $archivestart, average $average, scale $scale, seconds $seconds");
/* Deduce a interface if possible and use the description */
$curif = explode("-", $curdatabase);
$curif = "{$curif['0']}";
$friendly = convert_friendly_interface_to_friendly_descr(strtolower($curif));
if ($friendly == "") {
    $friendly = $curif;
}
$search = array("-", ".rrd", $curif);
$replace = array(" :: ", "", $friendly);
$prettydb = ucwords(str_replace($search, $replace, $curdatabase));
$rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
$uptime = "/usr/bin/uptime";
$sed = "/usr/bin/sed";
$havg = timeDiff($average, $defOptions);
$hperiod = timeDiff($seconds, $defOptions);
$data = true;
/* Don't leave it up to RRD Tool to select the RRA and resolution to use. */
/* Specify the RRA and resolution to use per the graph havg value. */
switch ($havg) {
    case "1 minute":
        $step = 60;
        break;
    case "5 minutes":
        $step = 300;
        break;
    case "1 hour":
        $step = 3600;
        break;
    case "1 day":
        $step = 86400;
开发者ID:nwholloway,项目名称:pfsense,代码行数:31,代码来源:status_rrd_graph_img.php

示例15: output

    output($GLOBALS['I18N']->get('Processed') . ' ' . $processed . ' ' . $GLOBALS['I18N']->get('out of') . ' ' . $num_users . ' ' . $GLOBALS['I18N']->get('users'));
    if ($num_users - $sent <= 0) {
        # this message is done
        if (!$someusers) {
            output($GLOBALS['I18N']->get('Hmmm, No users found to send to'));
        }
        if (!$failed_sent) {
            repeatMessage($messageid);
            $status = Sql_query(sprintf('update %s set status = "sent",sent = now() where id = %d', $GLOBALS['tables']['message'], $messageid));
            if (!empty($msgdata['notify_end']) && !isset($msgdata['end_notified'])) {
                $notifications = explode(',', $msgdata['notify_end']);
                foreach ($notifications as $notification) {
                    sendMail($notification, $GLOBALS['I18N']->get('Message Sending has finished'), sprintf($GLOBALS['I18N']->get('phplist has finished sending the message with subject %s'), $message['subject']));
                }
                Sql_Query(sprintf('insert ignore into %s (name,id,data) values("end_notified",%d,now())', $GLOBALS['tables']['messagedata'], $messageid));
            }
            $timetaken = Sql_Fetch_Row_query("select sent,sendstart from {$tables['message']} where id = \"{$messageid}\"");
            output($GLOBALS['I18N']->get('It took') . ' ' . timeDiff($timetaken[0], $timetaken[1]) . ' ' . $GLOBALS['I18N']->get('to send this message'));
            sendMessageStats($messageid);
        }
    } else {
        if ($script_stage < 5) {
            $script_stage = 5;
        }
    }
}
if (!$num_messages) {
    $script_stage = 6;
}
# we are done
# shutdown will take care of reporting
开发者ID:alancohen,项目名称:alancohenexperience-com,代码行数:31,代码来源:processqueue.php


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