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


PHP localtime函数代码示例

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


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

示例1: content

 /**
  * Renders this page in content mode.
  *
  * @return string  The page content.
  * @throws Wicked_Exception
  */
 public function content()
 {
     global $wicked;
     $days = (int) Horde_Util::getGet('days', 3);
     $summaries = $wicked->getRecentChanges($days);
     if (count($summaries) < 10) {
         $summaries = $wicked->mostRecent(10);
     }
     $bydate = array();
     $changes = array();
     foreach ($summaries as $page) {
         $page = new Wicked_Page_StandardPage($page);
         $createDate = $page->versionCreated();
         $tm = localtime($createDate, true);
         $createDate = mktime(0, 0, 0, $tm['tm_mon'], $tm['tm_mday'], $tm['tm_year'], $tm['tm_isdst']);
         $version_url = $page->pageUrl()->add('version', $page->version());
         $diff_url = Horde::url('diff.php')->add(array('page' => $page->pageName(), 'v1' => '?', 'v2' => $page->version()));
         $diff_alt = sprintf(_("Show changes for %s"), $page->version());
         $diff_img = Horde::img('diff.png', $diff_alt);
         $pageInfo = array('author' => $page->author(), 'name' => $page->pageName(), 'url' => $page->pageUrl(), 'version' => $page->version(), 'version_url' => $version_url, 'version_alt' => sprintf(_("Show version %s"), $page->version()), 'diff_url' => $diff_url, 'diff_alt' => $diff_alt, 'diff_img' => $diff_img, 'created' => $page->formatVersionCreated(), 'change_log' => $page->changeLog());
         $bydate[$createDate][$page->versionCreated()][$page->version()] = $pageInfo;
     }
     krsort($bydate);
     foreach ($bydate as $bysecond) {
         $day = array();
         krsort($bysecond);
         foreach ($bysecond as $pageList) {
             krsort($pageList);
             $day = array_merge($day, array_values($pageList));
         }
         $changes[] = array('date' => $day[0]['created'], 'pages' => $day);
     }
     return $changes;
 }
开发者ID:horde,项目名称:horde,代码行数:40,代码来源:RecentChanges.php

示例2: handleError

 /**
  * Handles an error
  *
  * @param $type string The type of the error
  * @param $string string The message of the error
  * @return bool
  */
 public function handleError($type, $string)
 {
     $msg = "";
     $caller = next(debug_backtrace());
     if (isset($caller["file"])) {
         $file = $caller["file"];
     } else {
         $file = "";
     }
     if (isset($caller["line"])) {
         $line = $caller["line"];
     } else {
         $line = 0;
     }
     date_default_timezone_set("Europe/Madrid");
     $localTime = time();
     $time = localtime($localTime, true);
     $errorExploded = explode("|", $string);
     $type = $errorExploded[0];
     $type = trim($type);
     $type = strtolower($type);
     if (count($errorExploded) >= 2) {
         $msg = trim($errorExploded[1]);
     } else {
         $type = "error";
         $msg = trim($string);
     }
     if ($msg == "") {
         $msg = $string;
     }
     return $this->_logError($type, $line, $msg, $file);
 }
开发者ID:andreums,项目名称:framework1.5,代码行数:39,代码来源:ErrorHandler.class.php

示例3: setTimezoneByOffset

function setTimezoneByOffset($offset)
{
    date_default_timezone_set('UTC');
    $testTimestamp = time();
    $testLocaltime = localtime($testTimestamp, true);
    $testHour = $testLocaltime['tm_hour'];
    $abbrarray = timezone_abbreviations_list();
    foreach ($abbrarray as $abbr) {
        foreach ($abbr as $city) {
            $val = false;
            if ($city['timezone_id'] != 'Factory' && '' . @$city['timezone_id'] > '') {
                if (isset($city['timezone_id'])) {
                    $val = date_default_timezone_set($city['timezone_id']);
                    if ($val) {
                        $testLocaltime = localtime($testTimestamp, true);
                        $hour = $testLocaltime['tm_hour'];
                        $testOffset = $hour - $testHour;
                        if ($testOffset == $offset || $testOffset == $offset + 24) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    date_default_timezone_set('UTC');
    return false;
}
开发者ID:phroun,项目名称:jeffutils,代码行数:28,代码来源:baseutils.php

示例4: show

 function show()
 {
     $this->html_header();
     $tasks = $this->db->getAll('SELECT permalink, postid, UNIX_TIMESTAMP(created_at) AS created_at, status FROM reblogs WHERE sessionkey = ? ORDER BY created_at DESC LIMIT 10', array($this->sessionkey));
     $link = $this->permalink;
     if (count($tasks) > 0) {
         foreach ($tasks as $k => $task) {
             $link = $task['permalink'];
             $classname = ($k + 1) % 2 ? 'odd' : 'even';
             print "<div class={$classname}>";
             print "<a href=\"{$link}\">post" . $task["postid"] . "</a>\n";
             print $task["status"] . "\n";
             $t = localtime($task["created_at"] + 9 * 3600, true);
             printf("%d.%d.%d %02d:%02d", $t['tm_year'] + 1900, $t['tm_mon'], $t['tm_mday'], $t['tm_hour'], $t['tm_min']);
             print "</div>";
         }
     }
     #$anchor = @$_REQUEST['anchor'];
     #header(
     #print (
     #	sprintf( "Location: /dashboard/%s?reblog=1&page=%s&anchor=%s&.rand=" . rand() . "#%s",
     #		$this->sessionkey,
     #		$this->page,
     #		$anchor,
     #		$anchor
     #	)
     #);
     $this->html_footer();
 }
开发者ID:ku,项目名称:reblog.ido.nu,代码行数:29,代码来源:Page_Class.php

示例5: quotaExpired

function quotaExpired($quotaString)
{
    if (!preg_match("/,/", $quotaString)) {
        return 0;
        // No timestamp == not expired.
    } else {
        list($quotaPart, $timestampPart) = explode(",", $quotaString, 2);
        $timestampPart = rtrim($timestampPart);
        $tsLength = strlen($timestampPart);
        if (strlen($tsLength) == 0) {
            return 0;
        } else {
            if (strlen($timestampPart) != 12) {
                return 1;
                // The safe thing to do, return expired on errors.
            }
        }
        // Convert the timestamp into a nice array.
        $timestampArray = array((int) substr($timestampPart, 0, 4), (int) substr($timestampPart, 4, 2), (int) substr($timestampPart, 6, 2), (int) substr($timestampPart, 8, 2), (int) substr($timestampPart, 10, 2));
        // Convert the localtime into a similar array.
        $currentTime = localtime();
        $currentTimeArray = array((int) $currentTime[5] + 1900, (int) $currentTime[4] + 1, (int) $currentTime[3], (int) $currentTime[2], (int) $currentTime[1]);
        // Check each of the five values (year, month, day, hour, minute) in the timestamp
        for ($counter = 0; $counter <= 4; $counter++) {
            if ($timestampArray[$counter] < $currentTimeArray[$counter]) {
                return 1;
            }
            if ($timestampArray[$counter] > $currentTimeArray[$counter]) {
                return 0;
            }
        }
        return 1;
    }
}
开发者ID:inkoss,项目名称:karoshi-server,代码行数:34,代码来源:get_quota.php

示例6: send_email

function send_email($user, $list, $filename, $to)
{
    $name = basename($filename);
    $file_type = "application/xml";
    // File Type
    $email_from = "dyi.Queen@hoana.com";
    // Who the email is from
    $a = localtime();
    $a[5] += 1900;
    $email_subject = "Updated " . $list . " list " . $a[5] . "-" . $a[4] . "-" . $a[3] . " " . $a[2] . ":" . $a[1] . ":" . $a[0];
    // The Subject of the email
    $email_txt = "This is " . $user . "'s " . $list . " list";
    // Message that the email has in it
    $email_to = $to;
    $headers = "From: " . $email_from;
    $file = fopen($filename, 'rb');
    $data = fread($file, filesize($filename));
    fclose($file);
    $semi_rand = md5(time());
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
    $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
    $email_message = "";
    $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_txt . "\n\n";
    $data = chunk_split(base64_encode($data));
    $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$file_type};\n" . " name=\"{$name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n";
    echo $email_to;
    echo $email_subject;
    echo $email_message;
    echo $headers;
    $ok = @mail($email_to, $email_subject, $email_message, $headers);
    return $ok;
}
开发者ID:uhdyi,项目名称:blacklist,代码行数:32,代码来源:emailfile.php

示例7: us_time_of_day_secs

/**
 * Obtain tide information using the shortcode [us_tides tide_url='tide feed xml url']
 * The format of the feed is expected to be as in the following output from bw_trace
 */
function us_time_of_day_secs()
{
    extract(localtime(time(), true));
    $secs = ($tm_hour * 60 + $tm_min) * 60 + $tm_sec;
    bw_trace($secs, __FUNCTION__, __LINE__, __FILE__, 'secs');
    return $secs;
}
开发者ID:bobbingwide,项目名称:us-tides,代码行数:11,代码来源:us-tides.php

示例8: reportingDate

function reportingDate(&$reportingmonth, &$reportdate)
{
    date_default_timezone_set('America/Detroit');
    $now = localtime();
    //for ($i=0; $i<6; $i++)
    //    print "now[" . $i . "]=" . $now[$i] . "\n";
    // Reporting Month
    // $now[4] = current month [0..11]
    $rm = $now[4];
    if ($now[3] > 25) {
        $rm = $rm + 1;
    }
    if ($rm > 11) {
        $rm = 0;
    }
    // Date report submitted
    $rn = $now;
    $rn[4] = $rm;
    //print "<p>mktime(" . 12 . "," . 0 . "," . 0 .
    //  "," . $rm . "," . ($now[3]) . "," . ($now[5]+1900) . ")</p>\n";
    $timestamp = mktime(12, 0, 0, $rm, $now[3], $now[5] + 1900);
    //print "<p>Timestamp:" . $timestamp . "</p>\n";
    //print "<P>D=" . strftime("%Y",$timestamp) . "-" . strftime("%b",$timestamp) . "-" . strftime("%d",$timestamp) . "</p>\n";
    $reportingmonth = strtoupper(strftime("%b", $timestamp));
    $reportdate = strtoupper(strftime("%b %d", mktime()));
    $period = ($now[5] - 101) * 12 + $now[3] - 1;
    return $period;
}
开发者ID:jjmcd,项目名称:mi-nts,代码行数:28,代码来源:PSHR_result_net.php

示例9: subtract

function subtract($time1, $time2)
{
    $years = $time2[0] - $time1[0];
    $months = $time2[1] - $time1[1];
    $days = $time2[2] - $time1[2];
    $hours = $time2[3] - $time1[3];
    $minutes = $time2[4] - $time1[4];
    $seconds = $time2[5] - $time1[5];
    if ($seconds < 0) {
        $seconds += 60;
        $minutes -= 1;
    }
    if ($minutes < 0) {
        $minutes += 60;
        $hours -= 1;
    }
    if ($hours < 0) {
        $hours += 24;
        $days -= 1;
    }
    if ($days < 0) {
        $months -= 1;
    }
    if ($months < 0) {
        $months += 12;
        $years -= 1;
    }
    if ($days < 0) {
        $date = localtime(mktime(12, 0, 0, $time2[1], 31, $time2[0]));
        $days_in_month = 31 - $date[3] ? 31 - $date[3] : 31;
        $days += $days_in_month;
    }
    return array($years, $months, $days, $hours, $minutes, $seconds);
}
开发者ID:markjreed,项目名称:reedville,代码行数:34,代码来源:ages.php

示例10: GetUptimeStatistics

 function GetUptimeStatistics($pointID, $channelID, $fromDate, $toDate)
 {
     $getUptimeStatistics = true;
     $fromParts = explode('-', $fromDate);
     $toParts = explode('-', $toDate);
     $this->p_fromDate = $fromParts[2] . '-' . $fromParts[0] . '-' . $fromParts[1];
     $this->p_toDate = $toParts[2] . '-' . $toParts[0] . '-' . $toParts[1];
     $sql = "select\n                  iss.PointObjectID,\n                  iss.ChannelID,\n                  count(*) ActualIntervals,\n                  (to_days('" . $this->p_toDate . "') - to_days('" . $this->p_fromDate . "'))*1440/p.ReadInterval +\n                  if('" . $this->p_toDate . "' = curdate(), floor(time_to_sec(curtime())/(60 * p.ReadInterval)), 1440/p.ReadInterval) ExpectedIntervals,\n                  date_sub(pcs.LastUnfilledIntervalDate,\n                           INTERVAL if((pcs.LastUnfilledIntervalDate >= '2006-04-02 06:00:00' and pcs.LastUnfilledIntervalDate <= '2006-10-29 06:00:00') or\n                                       (pcs.LastUnfilledIntervalDate >= '2007-03-11 06:00:00' and pcs.LastUnfilledIntervalDate <= '2007-11-04 06:00:00') or\n                                       (pcs.LastUnfilledIntervalDate >= '2008-03-09 06:00:00' and pcs.LastUnfilledIntervalDate <= '2008-11-02 06:00:00') or\n                                       (pcs.LastUnfilledIntervalDate >= '2009-03-08 06:00:00' and pcs.LastUnfilledIntervalDate <= '2009-11-01 06:00:00') or\n                                       (pcs.LastUnfilledIntervalDate >= '2010-03-07 06:00:00' and pcs.LastUnfilledIntervalDate <= '2010-11-07 06:00:00'), 4, 5) HOUR) LastIntervalDate\n                from\n                  t_intervalsettypes ist,\n                  t_intervalsets iss,\n                  t_intervals i,\n                  t_points p,\n                  t_pointchannelstatistics pcs\n                where\n                  ist.IntervalSetTypeName = 'IntervalSet' and\n                  iss.IntervalSetTypeID = ist.IntervalSetTypeID and\n                  iss.PointObjectID = " . $pointID . " and\n                  iss.ChannelID = " . $channelID . " and\n                  iss.IntervalSetBaseDate between '" . $this->p_fromDate . "' and '" . $this->p_toDate . "' and\n                  i.IntervalSetID = iss.IntervalSetID and\n                  (i.IsFilled = 0 or\n                  i.CreatedDate > i.UpdatedDate) and\n                  pcs.ObjectID = iss.PointObjectID and\n                  pcs.ChannelID = iss.ChannelID and\n                  p.ObjectID = pcs.ObjectID\n                group by\n                  iss.PointObjectID,\n                  iss.ChannelID";
     $result = mysql_query($sql, $this->sqlConnection());
     //$this->preDebugger($sql);
     if ($row = mysql_fetch_array($result)) {
         $this->p_actualIntervals = $row["ActualIntervals"];
         $this->p_expectedIntervals = round($row['ExpectedIntervals'], 0);
         $this->p_percentageUptime = round($this->p_actualIntervals / $this->p_expectedIntervals * 100.0, 2);
         $this->p_percentageFilled = round(100.0 - $this->p_percentageUptime, 2);
         $this->p_lastIntervalDate = $row["LastIntervalDate"];
     } else {
         $localTime = localtime(time(), true);
         $localSecs = ($localTime['tm_hour'] * 60 + $localTime['tm_min']) * 60 + $localTime['tm_sec'];
         $this->p_actualIntervals = 0;
         $this->p_expectedIntervals = (strtotime($toDate) - strtotime($fromDate)) / 300 + ($toDate == date("m-d-Y") ? floor($localSecs / 300) : 288);
         $this->p_percentageUptime = 0;
         $this->p_percentageFilled = "--";
         $this->p_lastIntervalDate = "??";
     }
     return $getUptimeStatistics;
 }
开发者ID:kelen303,项目名称:iEMS,代码行数:27,代码来源:Statistics.php

示例11: SendCommentsTwits

function SendCommentsTwits($debug)
{
    $default = 0;
    $Yesterday = mktime(0, 0, 0, date("m"), date("d") - (1 - $default), date("Y"));
    $LocalTime = localtime();
    if ($LocalTime[2] < 6) {
        $Today = $Yesterday;
        $Yesterday = mktime(0, 0, 0, date("m"), date("d") - (2 - $default), date("Y"));
    } else {
        $Today = mktime(0, 0, 0, date("m"), date("d") - $default, date("Y"));
    }
    $ThisDate = date("Y-m-d", $Yesterday);
    $qq = "select *,New_opinion.id as Oid, New_company.name as CompanyName from New_opinion,New_company,New_expert where\n\t\tNew_opinion.company_id = New_company.id and \n\t\tNew_opinion.expert_id=New_expert.id and  New_opinion.signal_id=6 and New_opinion.Date>=\"{$ThisDate}\"";
    // New_opinion.signal_id==3 is comment
    if ($debug) {
        echo "Query is <br>{$qq}<br>";
    }
    $result1 = mysql_query($qq);
    echo mysql_error();
    $NumAlerts = mysql_num_rows($result1);
    echo mysql_error();
    echo "Number of alerts is {$NumAlerts}<br>";
    if ($debug) {
        echo '<br>Debug';
    }
    for ($an = 0; $an < $NumAlerts; $an++) {
        $row1 = mysql_fetch_assoc($result1);
        //			foreach ($row1 as $key => $ra)
        //				echo  "<br>$key is $ra";
        //$cl = slink('http://www.stockchase.com/Company?ID='. $row1['company'],'','','','',$row1['company']);
        $cl = '#stock #invest #' . $row1['symbol'] . ' http://www.stockchase.com';
        $companyline = 'http://www.stockchase.com/company/view/' . $row1['company_id'] . '/' . $row1['Oid'];
        $companyline = getBitUrl($companyline);
        $companyname = $row1['CompanyName'];
        if (strlen($companyname > 10)) {
            $companyname = substr($companyname, 0, 7);
            $companyname .= '...';
        }
        $cl = $companyline . ' #trading #finance';
        //			$cl = 'http://www.stockchase.com/Opinion.php';
        //			$cl = 'http://tinyurl.com/5dqmwd';
        $twitterStatus = strip_tags($row1['comment']);
        $twitterStatus = str_replace('&nbsp', ' ', $twitterStatus);
        if (strlen($twitterStatus . $cl) > 140) {
            $twitterStatus1 = substr($twitterStatus, 0, 137 - strlen($cl));
            $twitterStatus = $twitterStatus1 . "...";
        }
        $twitterStatus .= $cl;
        echo '<br>';
        echo $twitterStatus;
        if ($debug) {
            echo "<br>{$an} Would send to twitter <b>{$twitterStatus}</b>";
        } else {
            //	$this->tweet->call('post','statuses/update',array('status' => $twitterStatus));
            echo shell_exec('/home/stockchase/EditorFunctions/python/mytweet.py "' . $twitterStatus . '"');
            flush();
            sleep(60 * 5);
        }
    }
}
开发者ID:iplayfast,项目名称:sc,代码行数:60,代码来源:SendTweet.php

示例12: update_timesheet

function update_timesheet($ts_finish)
{
    global $ts_no, $ts_start, $ts_description, $client_messages, $dow, $sow, $session;
    $session->Dbg("TimeSheet", "Updating timesheet for {$ts_finish}");
    $ts_finish = intval($ts_finish);
    if ($ts_no > 0 && $ts_finish > 0) {
        $session->Dbg("TimeSheet", "Write timesheet from {$ts_start} to {$ts_finish} for {$ts_no} '{$ts_description}'");
        $qry = new PgQuery("SELECT request_id FROM request WHERE request_id = ?", $ts_no);
        if (!$qry->Exec("TimeSheet") || $qry->rows == 0) {
            $client_messages[] = "WR # {$ts_no} was not found.";
            $session->Dbg("TimeSheet", "WR# {$ts_no} '{$ts_description}' was not found.");
        } else {
            $lt = localtime($sow, true);
            $session->Dbg("TimeSheet", "Time includes DST? " . $lt['tm_isdst']);
            $from = date('Y-M-d, H:i', $sow + $dow * 86400 + ($ts_start - 60 * $lt['tm_isdst']) * 60);
            $duration = sprintf("%d minutes", $ts_finish - $ts_start);
            $quantity = ($ts_finish - $ts_start) / 60;
            $description = ereg_replace("@\\|@.*\$", "", $ts_description);
            $sql = "INSERT INTO request_timesheet ( request_id, work_on, work_duration, work_quantity, work_by_id, work_description, work_units, entry_details ) ";
            $sql .= "VALUES( ?, ?::timestamp without time zone, ?::interval, ?, {$session->user_no}, ?, 'hours', ";
            $sql .= sprintf("'TS-%d-%d');", $session->user_no, $sow);
            $qry = new PgQuery($sql, $ts_no, $from, $duration, $quantity, $description);
            $qry->Exec("TimeSheet");
        }
    } else {
        $session->Dbg("TimeSheet", "Not writing timesheet from {$ts_start} to {$ts_finish} for {$ts_no} '{$ts_description}'");
    }
    $ts_no = 0;
    $ts_start = 0;
    $ts_description = "";
    return;
}
开发者ID:Br3nda,项目名称:wrms,代码行数:32,代码来源:timesheet-action.php

示例13: pleac_Finding_Today_s_Date

function pleac_Finding_Today_s_Date()
{
    define(SEP, '-');
    // ------------
    $today = getdate();
    $day = $today['mday'];
    $month = $today['mon'];
    $year = $today['year'];
    // Either do this to use interpolation:
    $sep = SEP;
    echo "Current date is: {$year}{$sep}{$month}{$sep}{$day}\n";
    // or simply concatenate:
    echo 'Current date is: ' . $year . SEP . $month . SEP . $day . "\n";
    // ------------
    $today = localtime(time(), TRUE);
    $day = $today['tm_mday'];
    $month = $today['tm_mon'] + 1;
    $year = $today['tm_year'] + 1900;
    printf("Current date is: %4d%s%2d%s%2d\n", $year, SEP, $month, SEP, $day);
    // ------------
    $format = 'Y' . SEP . 'n' . SEP . 'd';
    $today = date($format);
    echo "Current date is: {$today}\n";
    // ------------
    $sep = SEP;
    $today = strftime("%Y{$sep}%m{$sep}%d");
    echo "Current date is: {$today}\n";
}
开发者ID:tokenrove,项目名称:pfff,代码行数:28,代码来源:Finding_Today_s_Date.php

示例14: registraException

 function registraException($e)
 {
     $string = "ERRO: " . $e->getMessage() . ";CODIGO: " . $e->getCode() . ";ARQUIVO: " . $e->getFile() . ";LINHA: " . $e->getLine() . ";DATA: " . getdate() . " " . localtime() . "|";
     $pointer = fopen(BASEPATH . '/application/txt/exceptions.txt', 'w');
     fwrite($pointer, $string);
     fclose($pointer);
 }
开发者ID:mozelli,项目名称:portal-econocasa,代码行数:7,代码来源:funcoes.php

示例15: __construct

 function __construct()
 {
     $this->day = strtolower(date('l'));
     // monday, tuedsay ....
     $ltime = localtime();
     $this->time = $ltime[2] * 60 * 60 + $ltime[1] * 60 + $ltime[0];
     // seconds past in day
 }
开发者ID:TheBiggerGuy,项目名称:FreshAir,代码行数:8,代码来源:freshair_nownext.php


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