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


PHP gmmktime函数代码示例

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


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

示例1: display_tpotm

    public function display_tpotm($event)
    {
        $now = time();
        $date_today = gmdate("Y-m-d", $now);
        list($year_cur, $month_cur, $day1) = split('-', $date_today);
        // Start time for current month
        $month_start_cur = gmmktime(0, 0, 0, $month_cur, 1, $year_cur);
        $month_start = $month_start_cur;
        $month_end = $now;
        // group_id 5 = administrators
        // group_id 4 = global moderators
        // this groups belong to a Vanilla 3.1.x board
        $sql = 'SELECT u.username, u.user_id, u.user_colour, u.user_type, u.group_id, COUNT(p.post_id) AS total_posts
			FROM ' . USERS_TABLE . ' u, ' . POSTS_TABLE . ' p
				WHERE u.user_id > ' . ANONYMOUS . '
					AND u.user_id = p.poster_id
						AND p.post_time BETWEEN ' . $month_start . ' AND ' . $month_end . '
							AND (u.user_type <> ' . USER_FOUNDER . ')
								AND (u.group_id <> 5)
									AND (u.group_id <> 4)
			GROUP BY u.user_id
			ORDER BY total_posts DESC';
        $result = $this->db->sql_query_limit($sql, 1);
        $row = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        // let's go then..
        // posts made into the selected elapsed time
        $topm_tp = $row['total_posts'];
        $topm_un = get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']);
        // there is not a Top Poster, usually happens with fresh installations, where only the FOUNDER made the first post/topic. Or no normal users already did it.
        //Here TOPM_UN reflects this state.
        $this->template->assign_vars(array('TOPM_UN' => $topm_tp < 1 ? $topm_un = $this->user->lang['TOP_USERNAME_NONE'] : $topm_un, 'L_TPOTM' => $this->user->lang['TOP_CAT'], 'L_TOPM_UNA_L' => $this->user->lang['TOP_USERNAME'], 'L_TOPM_UPO_L' => sprintf($this->user->lang['TOP_USER_MONTH_POSTS'], $topm_tp), 'L_TOPM_POSTS_L' => $topm_tp > 1 || $topm_tp == 0 ? $this->user->lang['TOP_POSTS'] : $this->user->lang['TOP_POST']));
    }
开发者ID:alhitary,项目名称:tpotm,代码行数:33,代码来源:listener.php

示例2: post_notification_mysql2gmdate

function post_notification_mysql2gmdate($mysqlstring)
{
    if (empty($mysqlstring)) {
        return false;
    }
    return gmmktime((int) substr($mysqlstring, 11, 2), (int) substr($mysqlstring, 14, 2), (int) substr($mysqlstring, 17, 2), (int) substr($mysqlstring, 5, 2), (int) substr($mysqlstring, 8, 2), (int) substr($mysqlstring, 0, 4));
}
开发者ID:jrep20,项目名称:samcozen,代码行数:7,代码来源:functions.php

示例3: buildQuery

 /**
  * Builds the query for this datagrid
  *
  * @return array An array with two arguments containing the query and its parameters.
  */
 private function buildQuery()
 {
     $parameters = array($this->id);
     // start query, as you can see this query is build in the wrong place,
     // because of the filter it is a special case
     // wherein we allow the query to be in the actionfile itself
     $query = 'SELECT i.id, UNIX_TIMESTAMP(i.sent_on) AS sent_on
          FROM forms_data AS i
          WHERE i.form_id = ?';
     // add start date
     if ($this->filter['start_date'] !== '') {
         // explode date parts
         $chunks = explode('/', $this->filter['start_date']);
         // add condition
         $query .= ' AND i.sent_on >= ?';
         $parameters[] = BackendModel::getUTCDate(null, gmmktime(23, 59, 59, $chunks[1], $chunks[0], $chunks[2]));
     }
     // add end date
     if ($this->filter['end_date'] !== '') {
         // explode date parts
         $chunks = explode('/', $this->filter['end_date']);
         // add condition
         $query .= ' AND i.sent_on <= ?';
         $parameters[] = BackendModel::getUTCDate(null, gmmktime(23, 59, 59, $chunks[1], $chunks[0], $chunks[2]));
     }
     // new query
     return array($query, $parameters);
 }
开发者ID:bwgraves,项目名称:forkcms,代码行数:33,代码来源:Data.php

示例4: setTime

 /**
  * Set the time
  * @access protected This class is immutable, so this is protected. Only the constructor calls it.
  */
 protected function setTime($hour = null, $minute = null, $second = null, $rollover = null)
 {
     if (is_null($hour)) {
         $hour = gmdate("H");
     }
     if (is_null($minute)) {
         $minute = gmdate("i");
     }
     if (is_null($second)) {
         $second = gmdate("s");
     }
     if (is_null($rollover)) {
         $rollover = false;
     }
     if (!$rollover) {
         if ($hour > 23 || $minute > 59 || $second > 59) {
             throw new qCal_DateTime_Exception_InvalidTime(sprintf("Invalid time specified for qCal_Time: \"%02d:%02d:%02d\"", $hour, $minute, $second));
         }
     }
     // since PHP is incapable of storing a time without a date, we use the first day of
     // the unix epoch so that we only have the amount of seconds since the zero of unix epoch
     // we only use gm here because we don't want the server's timezone to interfere
     $time = gmmktime($hour, $minute, $second, 1, 1, 1970);
     $this->time = $time;
     $formatString = "a|A|B|g|G|h|H|i|s|u";
     $keys = explode("|", $formatString);
     $vals = explode("|", gmdate($formatString, $this->getTimestamp(false)));
     $this->timeArray = array_merge($this->timeArray, array_combine($keys, $vals));
     return $this;
 }
开发者ID:yozhi,项目名称:YetiForceCRM,代码行数:34,代码来源:Time.php

示例5: _init

 /**
  * This method parses branches even though RCS doesn't support
  * branches. But rlog from the RCS tools supports them, and displays them
  * even on RCS repositories.
  */
 protected function _init()
 {
     $raw = $this->_file->getAccum();
     /* Initialise a simple state machine to parse the output of rlog */
     $state = 'init';
     while (!empty($raw) && $state != 'done') {
         switch ($state) {
             /* Found filename, now looking for the revision number */
             case 'init':
                 $line = array_shift($raw);
                 if (preg_match("/revision (.+)\$/", $line, $parts)) {
                     $this->_rev = $parts[1];
                     $state = 'date';
                 }
                 break;
                 /* Found revision and filename, now looking for date */
             /* Found revision and filename, now looking for date */
             case 'date':
                 $line = array_shift($raw);
                 if (preg_match("|^date:\\s+(\\d+)[-/](\\d+)[-/](\\d+)\\s+(\\d+):(\\d+):(\\d+).*?;\\s+author:\\s+(.+);\\s+state:\\s+(\\S+);(\\s+lines:\\s+\\+(\\d+)\\s\\-(\\d+))?|", $line, $parts)) {
                     $this->_date = gmmktime($parts[4], $parts[5], $parts[6], $parts[2], $parts[3], $parts[1]);
                     $this->_author = $parts[7];
                     $this->_state = $parts[8];
                     if (isset($parts[9])) {
                         $this->_lines = '+' . $parts[10] . ' -' . $parts[11];
                         $this->_files[$this->_file->getSourcerootPath()] = array('added' => $parts[10], 'deleted' => $parts[11]);
                     }
                     $state = 'branches';
                 }
                 break;
                 /* Look for a branch point here - format is 'branches:
                  * x.y.z; a.b.c;' */
             /* Look for a branch point here - format is 'branches:
              * x.y.z; a.b.c;' */
             case 'branches':
                 /* If we find a branch tag, process and pop it,
                    otherwise leave input stream untouched */
                 if (!empty($raw) && preg_match("/^branches:\\s+(.*)/", $raw[0], $br)) {
                     /* Get the list of branches from the string, and
                      * push valid revisions into the branches array */
                     $brs = preg_split('/;\\s*/', $br[1]);
                     foreach ($brs as $brpoint) {
                         if ($this->_rep->isValidRevision($brpoint)) {
                             $this->_branches[] = $brpoint;
                         }
                     }
                     array_shift($raw);
                 }
                 $state = 'done';
                 break;
         }
     }
     /* Assume the rest of the lines are the log message */
     $this->_log = implode("\n", $raw);
     $this->_tags = $this->_file->getRevisionSymbol($this->_rev);
     $this->_setSymbolicBranches();
     $branches = $this->_file->getBranches();
     $key = array_keys($branches, $this->_rev);
     $this->_branch = empty($key) ? array_keys($branches, $this->_rep->strip($this->_rev, 1)) : $key;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:65,代码来源:Rcs.php

示例6: xfac_sync_mysqlDateToGmtTimestamp

function xfac_sync_mysqlDateToGmtTimestamp($string)
{
    if (preg_match('/^(\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)$/', trim($string), $m)) {
        return gmmktime($m[4], $m[5], $m[6], $m[2], $m[3], $m[1]);
    }
    return 0;
}
开发者ID:burtay,项目名称:bdApi,代码行数:7,代码来源:sync.php

示例7: __construct

 /**
  * Initiate current time list.
  *
  * @param Ai1ec_Registry_Object $registry
  *
  * @return void
  */
 public function __construct(Ai1ec_Registry_Object $registry)
 {
     parent::__construct($registry);
     $gmt_time = version_compare(PHP_VERSION, '5.1.0') >= 0 ? time() : gmmktime();
     $this->_current_time = array((int) $_SERVER['REQUEST_TIME'], $gmt_time);
     $this->_gmtdates = $registry->get('cache.memory');
 }
开发者ID:sedici,项目名称:wpmu-istec,代码行数:14,代码来源:system.php

示例8: getDefaultFileName

 public static function getDefaultFileName($time = null)
 {
     if (empty($time)) {
         $time = gmmktime();
     }
     return self::$filePrefix . gmdate('d_M_Y-H_i_s-T', $time) . '.zip';
 }
开发者ID:hbsman,项目名称:vtigercrm-5.3.0-ja,代码行数:7,代码来源:BackupZip.php

示例9: smarty_modifier_nicetime

function smarty_modifier_nicetime($string)
{
    if (ereg('(19|20[0-9]{2})[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01]) ([012 ][0-9])[: .]([0-5][0-9])[: .]([0-5][0-9])[ \\.].*', $string, $regs)) {
        $unixtime = gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
        $time = time() + 28800 - $unixtime;
        if ($time < 24 * 3600 * 5) {
            if ($time < 48 * 3600) {
                if ($time < 24 * 3600) {
                    if ($time < 5 * 3600) {
                        if ($time < 3600) {
                            if ($time < 60) {
                                return $time . '秒前';
                            } else {
                                return floor($time / 60) . '分钟前';
                            }
                        } else {
                            $min = floor($time % 3600 / 60);
                            return floor($time / 3600) . '小时' . ($min > 0 ? $min . '分钟' : '') . '前';
                        }
                    } else {
                        return '今天 ' . $regs[4] . ':' . $regs[5] . ':' . $regs[6];
                    }
                } else {
                    return '昨天';
                }
            } else {
                return floor($time / (24 * 3600)) . '天前';
            }
        } else {
            return $string;
        }
    } else {
        return $string;
    }
}
开发者ID:dalinhuang,项目名称:shopexts,代码行数:35,代码来源:modifier.nicetime.php

示例10: wp_days_ago

function wp_days_ago($mode = 0, $prepend = "", $append = "", $texts = array("Today", "Yesterday", "One week ago", "days ago", "year", "years", "ago", "day ago", "days ago", "Just now", "One minute ago", "minutes ago", "1 hour ago", "hours ago", "Some time in the future"))
{
    $days = round((strtotime(date("Y-m-d", gmmktime() + get_option('gmt_offset') * 3600)) - strtotime(date("Y-m-d", get_the_time("U")))) / 86400);
    $minutes = round((strtotime(date("Y-m-d H:i", gmmktime() + get_option('gmt_offset') * 3600)) - strtotime(date("Y-m-d H:i", get_the_time("U")))) / 60);
    $output = $prepend;
    if ($minutes < 0) {
        $output .= $texts[14];
    } else {
        if ($mode == 0 && $minutes < 1440) {
            if ($minutes == 0) {
                $output .= $texts[9];
            } else {
                if ($minutes == 1) {
                    $output .= $texts[10];
                } else {
                    if ($minutes < 60) {
                        $output .= $minutes . " " . $texts[11];
                    } else {
                        if ($minutes < 120) {
                            $output .= $texts[12];
                        } else {
                            $output .= floor($minutes / 60) . " " . $texts[13];
                        }
                    }
                }
            }
        } else {
            if ($days == 0) {
                $output = $output . $texts[0];
            } elseif ($days == 1) {
                $output = $output . $texts[1];
            } elseif ($days == 7) {
                $output = $output . $texts[2];
            } else {
                $years = floor($days / 365);
                if ($years > 0) {
                    if ($years == 1) {
                        $yearappend = $texts[4];
                    } else {
                        $yearappend = $texts[5];
                    }
                    $days = $days - 365 * $years;
                    if ($days == 0) {
                        $output = $output . $years . " " . $yearappend . " " . $texts[6];
                    } else {
                        if ($days == 1) {
                            $output = $output . $years . " " . $yearappend . ", " . $days . " " . $texts[7];
                        } else {
                            $output = $output . $years . " " . $yearappend . ", " . $days . " " . $texts[8];
                        }
                    }
                } else {
                    $output = $output . $days . " " . $texts[3];
                }
            }
        }
    }
    $output = $output . $append;
    echo $output;
}
开发者ID:alphaomegahost,项目名称:FIN,代码行数:60,代码来源:wp_days_ago.php

示例11: run_gmgetdate_assertion

 protected function run_gmgetdate_assertion()
 {
     $expected = time();
     $date_array = phpbb_gmgetdate($expected);
     $actual = gmmktime($date_array['hours'], $date_array['minutes'], $date_array['seconds'], $date_array['mon'], $date_array['mday'], $date_array['year']);
     $this->assertEquals($expected, $actual);
 }
开发者ID:josh-js,项目名称:phpbb,代码行数:7,代码来源:gmgetdate_test.php

示例12: _createElements

 function _createElements()
 {
     $this->_elements = array();
     for ($i = 1; $i <= 31; $i++) {
         $days[$i] = $i;
     }
     for ($i = 1; $i <= 12; $i++) {
         $months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), "%B");
     }
     for ($i = $this->_options['startyear']; $i <= $this->_options['stopyear']; $i++) {
         $years[$i] = $i;
     }
     $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes(), true);
     $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes(), true);
     $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes(), true);
     // If optional we add a checkbox which the user can use to turn if on
     if ($this->_options['optional']) {
         $this->_elements[] =& MoodleQuickForm::createElement('checkbox', 'off', null, get_string('disable'), $this->getAttributes(), true);
     }
     foreach ($this->_elements as $element) {
         if (method_exists($element, 'setHiddenLabel')) {
             $element->setHiddenLabel(true);
         }
     }
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:25,代码来源:dateselector.php

示例13: ewiki_decode_datetime

function ewiki_decode_datetime($str, $localize = 1, $gmt = 0)
{
    $done = 0;
    $months = array_flip(array("Err", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"));
    #-- 8601
    if ($str[4] == "-" and preg_match("/(\\d+)-(\\d+)-(\\d+)(T(\\d+):(\\d+)(:(\\d+))?)?/", $str, $uu)) {
        $t = gmmktime($uu[5], $uu[6], $uu[8], $uu[2], $uu[3], $uu[1]);
    } elseif ($str[3] == " " and preg_match("/\\w+ (\\w+) +(\\d+) (\\d+):(\\d+):(\\d+) (\\d+)/", $str, $uu)) {
        $t = gmmktime($uu[3], $uu[4], $uu[5], $months[$uu[1]], $uu[2], $uu[6]);
        $gmt = 1;
    } elseif (1 and preg_match("/\\w+, (\\d+)[- ](\\w+)[- ](\\d+) (\\d+):(\\d+):(\\d+)/", $str, $uu)) {
        $t = gmmktime($uu[4], $uu[5], $uu[6], $months[$uu[2]], $uu[1], $uu[3]);
        $gmt = 1;
    } elseif ((int) $str == $str) {
        $t = (int) $str;
        $gmt = 1;
    } else {
        $t = strtotime($str);
        $gmt = 1;
    }
    #-- is local time (iso8601 only)
    if (!$gmt && $localize && preg_match('/([+-])(\\d+):(\\d+)$/', $str, $uu)) {
        $dt = $uu[1] * 60 + $uu[2];
        if ($uu[1] == "+") {
            $t -= $dt;
        } else {
            $t += $dt;
        }
    }
    return $t;
}
开发者ID:gpuenteallott,项目名称:rox,代码行数:31,代码来源:feedparse.php

示例14: number2Ts

 static function number2Ts($dateValue = 0, $base = 'win')
 {
     if ($base == 'win') {
         // Base date of 1st Jan 1900 = 1.0
         $myExcelBaseDate = 25569;
         //  Adjust for the spurious 29-Feb-1900 (Day 60)
         if ($dateValue < 60) {
             --$myExcelBaseDate;
         }
     } else {
         // Base date of 2nd Jan 1904 = 1.0
         $myExcelBaseDate = 24107;
     }
     // Perform conversion
     if ($dateValue >= 1) {
         $utcDays = $dateValue - $myExcelBaseDate;
         $returnValue = round($utcDays * 24 * 60 * 60);
         if ($returnValue <= PHP_INT_MAX && $returnValue >= -PHP_INT_MAX) {
             $returnValue = (int) $returnValue;
         }
     } else {
         $hours = round($dateValue * 24);
         $mins = round($dateValue * 24 * 60) - round($hours * 60);
         $secs = round($dateValue * 24 * 60 * 60) - round($hours * 60 * 60) - round($mins * 60);
         $returnValue = (int) gmmktime($hours, $mins, $secs);
     }
     // Return
     return $returnValue;
 }
开发者ID:trevorpao,项目名称:f3cms,代码行数:29,代码来源:XlsReadFilter.php

示例15: createEmail

 public static function createEmail($id = '', $override = array())
 {
     global $timedate;
     $time = mt_rand();
     $name = 'SugarEmail';
     $email = new Email();
     $email->name = $name . $time;
     $email->type = 'out';
     $email->status = 'sent';
     $email->date_sent = $timedate->to_display_date_time(gmdate("Y-m-d H:i:s", gmmktime() - 3600 * 24 * 2));
     // Two days ago
     if (!empty($id)) {
         $email->new_with_id = true;
         $email->id = $id;
     }
     foreach ($override as $key => $value) {
         $email->{$key} = $value;
     }
     $email->save();
     if (!empty($override['parent_id']) && !empty($override['parent_type'])) {
         self::createEmailsBeansRelationship($email->id, $override['parent_type'], $override['parent_id']);
     }
     self::$_createdEmails[] = $email;
     return $email;
 }
开发者ID:nartnik,项目名称:sugarcrm_test,代码行数:25,代码来源:SugarTestEmailUtilities.php


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