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


PHP mktime函数代码示例

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


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

示例1: getCache

 public static function getCache($dir, $cacheName, $maxAge, $deserialize = false, $plainCache = false)
 {
     if (is_dir($dir)) {
         $cacheFile = $dir . $cacheName;
         if (is_file($cacheFile)) {
             // get file stats
             $fileInfo = stat($cacheFile);
             $lastModified = $fileInfo['mtime'];
             $now = mktime();
             //echo '<p>time now = ' . $now;
             $diff = $now - $lastModified;
             //echo '<p>time elapsed = ' .$diff;
             if ($diff >= $maxAge) {
                 //echo 'clearing cache';
                 unlink($cacheFile);
                 return false;
             }
             //echo '<p>returning cache';
             if ($deserialize == false && $plainCache == false) {
                 include_once $cacheFile;
             } else {
                 if ($deserialize == false && $plainCache) {
                     $data = file_get_contents($cacheFile);
                 } else {
                     $data = unserialize(file_get_contents($cacheFile));
                 }
             }
             return $data;
         } else {
             return false;
         }
     }
 }
开发者ID:rashijani,项目名称:dragonphp,代码行数:33,代码来源:CacheHelper.php

示例2: getBuyDate

 function getBuyDate($contents)
 {
     $matchesarray = array();
     preg_match_all("/(\\d\\d [A-Z][a-z][a-z] \\d{4})/", $contents, $matchesarray);
     $datetimestamp = date('U');
     for ($i = 0; $i < count($matchesarray[0]) / 2; $i++) {
         $maDate = $matchesarray[0][$i * 2];
         $maDate = str_replace(' ', '-', $maDate);
         $maDate = str_replace('Jan', '01', $maDate);
         $maDate = str_replace('Feb', '02', $maDate);
         $maDate = str_replace('Mar', '03', $maDate);
         $maDate = str_replace('Apr', '04', $maDate);
         $maDate = str_replace('May', '05', $maDate);
         $maDate = str_replace('Jun', '06', $maDate);
         $maDate = str_replace('Jul', '07', $maDate);
         $maDate = str_replace('Aug', '08', $maDate);
         $maDate = str_replace('Sep', '09', $maDate);
         $maDate = str_replace('Oct', '10', $maDate);
         $maDate = str_replace('Nov', '11', $maDate);
         $maDate = str_replace('Dec', '12', $maDate);
         list($jour, $mois, $annee) = explode('-', $maDate);
         $maDate = date("U", mktime(0, 0, 0, $mois, $jour, $annee));
         if ($maDate < $datetimestamp) {
             $datetimestamp = $maDate;
         }
     }
     $maDate = date("Y-m-d", $datetimestamp);
     return $maDate;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:29,代码来源:hp.class.php

示例3: diffDate

function diffDate($d1, $d2, $type = '', $sep = '-')
{
    $d1 = explode($sep, $d1);
    $d2 = explode($sep, $d2);
    switch ($type) {
        case 'A':
            $X = 31536000;
            break;
        case 'M':
            $X = 2592000;
            break;
        case 'D':
            $X = 86400;
            break;
        case 'H':
            $X = 3600;
            break;
        case 'MI':
            $X = 60;
            break;
        default:
            $X = 1;
    }
    echo $d2[1];
    echo $d2[2];
    echo $d2[0];
    return floor((mktime(0, 0, 0, $d2[1], $d2[2], $d2[0]) - mktime(0, 0, 0, $d1[1], $d1[2], $d1[0])) / $X);
}
开发者ID:sjaviel,项目名称:programacao_internet_2015_2,代码行数:28,代码来源:diff-dates.php

示例4: dateToUnix

 public function dateToUnix($datum, $stunde = "1")
 {
     $tag = $datum[0] . $datum[1];
     $monat = $datum[3] . $datum[4];
     $jahr = $datum[6] . $datum[7] . $datum[8] . $datum[9];
     return mktime($stunde, "0", "0", $monat, $tag, $jahr);
 }
开发者ID:robert-hanke,项目名称:Raumbelegungen,代码行数:7,代码来源:raumbelegung.php

示例5: energy_time

 /**
  * 时刻记录
  * Enter description here ...
  */
 public function energy_time()
 {
     $uid = I('uid', '0', 'intval');
     $start_time = mktime(0, 0, 0, date("m"), 1, date("Y"));
     $end_time = mktime(23, 59, 59, date("m"), date("t"), date("Y"));
     $res = $this->_mod->where('uid =' . $uid . ' and add_time >= ' . $start_time . ' and add_time <= ' . $end_time)->order('add_time')->select();
     $date_array = array();
     foreach ($res as $key => $val) {
         $res[$key]['add_time'] = date('m.d', $val['add_time']);
         $res[$key]['time'] = date('H:i', $val['add_time']);
         if (!in_array($res[$key]['add_time'], $date_array)) {
             array_push($date_array, $res[$key]['add_time']);
         }
     }
     foreach ($date_array as $value) {
         foreach ($res as $k => $v) {
             if ($value == $v['add_time']) {
                 $result[$v['add_time']][] = $v;
                 //按日期分组
             }
         }
     }
     $appjson = $result;
     if (C('APP_JSON_RETURN')) {
         $this->jsonReturn($appjson);
     }
 }
开发者ID:lzstg,项目名称:guangchangwu_web,代码行数:31,代码来源:energyAction.class.php

示例6: testWhere

 public function testWhere()
 {
     self::$db->select('account', 'user_name', ['email' => 'foo@bar.com']);
     $sql = 'SELECT "user_name" FROM "account" WHERE "email" = \'foo@bar.com\'';
     $this->assertEquals($sql, self::$db->lastQuery());
     self::$db->select('account', 'user_name', ['user_id' => 200]);
     $sql = 'SELECT "user_name" FROM "account" WHERE "user_id" = 200';
     $this->assertEquals($sql, self::$db->lastQuery());
     self::$db->select('account', 'user_name', ['user_id[>]' => 200]);
     $sql = 'SELECT "user_name" FROM "account" WHERE "user_id" > 200';
     $this->assertEquals($sql, self::$db->lastQuery());
     self::$db->select('account', 'user_name', ['user_id[>=]' => 200]);
     $sql = 'SELECT "user_name" FROM "account" WHERE "user_id" >= 200';
     $this->assertEquals($sql, self::$db->lastQuery());
     self::$db->select('account', 'user_name', ['user_id[!]' => 200]);
     $sql = 'SELECT "user_name" FROM "account" WHERE "user_id" != 200';
     $this->assertEquals($sql, self::$db->lastQuery());
     self::$db->select('account', 'user_name', ['age[<>]' => [200, 500]]);
     $sql = 'SELECT "user_name" FROM "account" WHERE ("age" BETWEEN 200 AND 500)';
     $this->assertEquals($sql, self::$db->lastQuery());
     self::$db->select('account', 'user_name', ['age[><]' => [200, 500]]);
     $sql = 'SELECT "user_name" FROM "account" WHERE ("age" NOT BETWEEN 200 AND 500)';
     $this->assertEquals($sql, self::$db->lastQuery());
     $now = date('Y-m-d');
     self::$db->select('account', 'user_name', ['birthday[><]' => [date('Y-m-d', mktime(0, 0, 0, 1, 1, 2015)), $now]]);
     $sql = 'SELECT "user_name" FROM "account" WHERE ("birthday" NOT BETWEEN \'2015-01-01\' AND \'' . $now . '\')';
     $this->assertEquals($sql, self::$db->lastQuery());
     self::$db->select('account', 'user_name', ['OR' => ['user_id' => [2, 123, 234, 54], 'email' => ['foo@bar.com', 'cat@dog.com', 'admin@medoo.in']]]);
     $sql = 'SELECT "user_name" FROM "account" WHERE "user_id" IN (2,123,234,54) OR "email" IN (\'foo@bar.com\',\'cat@dog.com\',\'admin@medoo.in\')';
     $this->assertEquals($sql, self::$db->lastQuery());
     // [Negative condition]
     self::$db->select('account', 'user_name', ['AND' => ['user_name[!]' => 'foo', 'user_id[!]' => 1024, 'email[!]' => ['foo@bar.com', 'cat@dog.com', 'admin@medoo.in'], 'city[!]' => null, 'promoted[!]' => true]]);
     $sql = 'SELECT "user_name" FROM "account" WHERE "user_name" != \'foo\' AND "user_id" != 1024 AND "email" NOT IN (\'foo@bar.com\',\'cat@dog.com\',\'admin@medoo.in\') AND "city" IS NOT NULL AND "promoted" != 1';
     $this->assertEquals($sql, self::$db->lastQuery());
 }
开发者ID:panada,项目名称:medoo,代码行数:35,代码来源:SelectTest.php

示例7: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     uc_payment_enter($form_state->getValue('order_id'), 'check', $form_state->getValue('amount'), $this->currentUser()->id(), '', $form_state->getValue('comment'));
     db_insert('uc_payment_check')->fields(array('order_id' => $form_state->getValue('order_id'), 'clear_date' => mktime(12, 0, 0, $form_state->getValue('clear_month'), $form_state->getValue('clear_day'), $form_state->getValue('clear_year'))))->execute();
     drupal_set_message($this->t('Check received, expected clear date of @date.', ['@date' => uc_date_format($form_state->getValue('clear_month'), $form_state->getValue('clear_day'), $form_state->getValue('clear_year'))]));
     $form_state->setRedirect('uc_order.admin_view', ['uc_order' => $form_state->getValue('order_id')]);
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:10,代码来源:ReceiveCheckForm.php

示例8: subDays

 public static function subDays($date, $days)
 {
     $d = self::formatDate($date);
     $d = date_parse($d);
     $d = mktime($d['hour'], $d['minute'], $d['second'], $d['month'], $d['day'] - $days, $d['year']);
     return self::formatDate($d);
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:7,代码来源:PagSeguroHelper.class.php

示例9: run

 public function run()
 {
     $today = array();
     $tomorrow = array();
     $nextDay = array();
     $name = Yii::app()->user->getName();
     $tD = mktime(0, 0, 0, date("m"), date("d"), date("Y"));
     $tM = mktime(0, 0, 0, date("m"), date("d") + 1, date("Y"));
     $nD = mktime(0, 0, 0, date("m"), date("d") + 2, date("Y"));
     $query = "SELECT * FROM x2_actions WHERE assignedTo = '" . $name . "' OR 'Anyone'";
     $command = Yii::app()->db->createCommand($query);
     $result = $command->queryAll();
     foreach ($result as $row) {
         $dueDate = $row['dueDate'];
         if ($row['dueDate'] == $tD) {
             $today[] = $row;
         } else {
             if ($row['dueDate'] == $tM) {
                 $tomorrow[] = $row;
             } else {
                 if ($row['dueDate'] == $nD) {
                     $nextDay[] = $row;
                 }
             }
         }
     }
     $this->render('reminders', array('tD' => $tD, 'today' => $today, 'tomorrow' => $tomorrow, 'nextDay' => $nextDay));
 }
开发者ID:netconstructor,项目名称:X2Engine,代码行数:28,代码来源:Reminders.php

示例10: beforeFilter

 function beforeFilter()
 {
     $this->Auth->authError = $this->Auth->user() ? 'Sorry, you do not have access to that location.' : 'Please <a href="/login">log in</a> before you try that.';
     $deadline = mktime(0, 0, 0, 8, 1, 2015);
     $this->band_applications_open = time() < $deadline;
     $this->set(array('band_applications_open' => $this->band_applications_open));
 }
开发者ID:BallStateCBER,项目名称:muncieMusicFest,代码行数:7,代码来源:app_controller.php

示例11: populate_cedole

function populate_cedole()
{
    $bond_factory = new Bond();
    $today = date('Y-m-d');
    // $bonds = $bond_factory->find_all(array('where_clause' => "`stacco` != '0000-00-00' AND `cadenza` > 0 AND `scadenza` > '{$today}'"));
    $bonds = $bond_factory->find_all(array('where_clause' => "`cadenza` > 0 AND `scadenza` > '{$today}'"));
    // print_r($bonds);
    foreach ($bonds as $bond) {
        if ($bond->stacco != '0000-00-00') {
            $s = strtotime($bond->stacco);
            $k = 1;
        } else {
            $s = strtotime($bond->scadenza);
            $k = -1;
        }
        $d = $today = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
        $c = 0;
        while ($d >= $today && $d <= $s) {
            $m = date('n', $s) + $c;
            $d = mktime(0, 0, 0, $m, date('d', $s), date('Y'));
            $cedola = new Cedola(array('isin' => $bond->isin, 'stacco' => date('Y-m-d', $d), 'tasso' => $bond->tasso));
            $cedola->_force_create = TRUE;
            $cedola->_ignore = TRUE;
            $cedola->save();
            $c += $k * $bond->cadenza;
        }
    }
}
开发者ID:emeraldion,项目名称:creso,代码行数:28,代码来源:populate_cedole.php

示例12: enviarEmailAluno

function enviarEmailAluno($tipoEmail)
{
    global $system;
    switch ($tipoEmail) {
        case 1:
            $periodo = date('Y-m-d', mktime(23, 59, 59, date('m'), date('d') + 1, date('Y')));
            break;
        case 2:
            $periodo = date('Y-m-d', mktime(23, 59, 59, date('m'), date('d') + 5, date('Y')));
            break;
        case 3:
            $periodo = date('Y-m-d', mktime(23, 59, 59, date('m'), date('d') + 10, date('Y')));
            break;
    }
    $assinaturas = $system->planos->getPlanosAluno("excluido = 0 and data_expiracao = '" . $periodo . "'");
    if (count($assinaturas)) {
        foreach ($assinaturas as $assinatura) {
            switch ($tipoEmail) {
                case 1:
                    $system->email_model->expiraAssinatura1DiaAluno($assinatura['usuario_id'], $assinatura['plano_id']);
                    break;
                case 2:
                    $system->email_model->expiraAssinatura5DiaAluno($assinatura['usuario_id'], $assinatura['plano_id']);
                    break;
                case 3:
                    $system->email_model->expiraAssinatura10DiaAluno($assinatura['usuario_id'], $assinatura['plano_id']);
                    break;
            }
        }
    }
}
开发者ID:eltonsarmento,项目名称:CursosIAG,代码行数:31,代码来源:cron_acesso_assinaturas.php

示例13: setCookieValue

 /**
  * Set Cookie Value
  *
  * @param string $key
  * @param $value
  * @return void
  */
 public function setCookieValue($key, $value, $exp = NULL)
 {
     if ($key) {
         $exp = $exp ? $exp : mktime(0, 0, 0, 12, 32, 2080);
         setcookie('Tx_Nboevents_Reservation_' . $key, serialize($value), $exp, "/");
     }
 }
开发者ID:noelboss,项目名称:nboevents,代码行数:14,代码来源:Cookies.php

示例14: setCalendar

function setCalendar($inYear, $inMonth)
{
    $dayofmonth = date('t', mktime(0, 0, 0, $inMonth, 1, $inYear));
    $day_count = 1;
    $num = 0;
    for ($i = 0; $i < 7; $i++) {
        $dayofweek = date('w', mktime(0, 0, 0, $inMonth, $day_count, $inYear));
        $dayofweek = $dayofweek - 1;
        if ($dayofweek == -1) {
            $dayofweek = 6;
        }
        if ($dayofweek == $i) {
            $week[$num][$i] = $day_count;
            $day_count++;
        } else {
            $week[$num][$i] = "";
        }
    }
    while (true) {
        $num++;
        for ($i = 0; $i < 7; $i++) {
            $week[$num][$i] = $day_count;
            $day_count++;
            if ($day_count > $dayofmonth) {
                break;
            }
        }
        if ($day_count > $dayofmonth) {
            break;
        }
    }
    setView($week);
}
开发者ID:njn07,项目名称:CMP_Lab1,代码行数:33,代码来源:calendar.php

示例15: _createContent

 public function _createContent(&$toReturn)
 {
     $ppo = new CopixPPO();
     // Récupération des paramètres
     $ppo->cahierId = $this->getParam('cahierId');
     $ppo->jour = $this->getParam('date_jour');
     $ppo->mois = $this->getParam('date_mois');
     $ppo->annee = $this->getParam('date_annee');
     $ppo->eleve = $this->getParam('eleve');
     $time = mktime(0, 0, 0, $ppo->mois, $ppo->jour, $ppo->annee);
     $cahierInfos = Kernel::getModParent('MOD_CAHIERDETEXTES', $ppo->cahierId);
     $nodeId = isset($cahierInfos[0]) ? $cahierInfos[0]->node_id : null;
     $ppo->niveauUtilisateur = Kernel::getLevel('MOD_CAHIERDETEXTES', $ppo->cahierId);
     $estAdmin = $ppo->niveauUtilisateur >= PROFILE_CCV_PUBLISH ? true : false;
     // Récupération des mémos suivant les accès de l'utilisateur courant (élève / responsable / enseignant)
     $memoDAO = _ioDAO('cahierdetextes|cahierdetextesmemo');
     if ($estAdmin) {
         $ppo->memos = $memoDAO->findByClasse($nodeId, true);
     } elseif (Kernel::getLevel('MOD_CAHIERDETEXTES', $ppo->cahierId) == PROFILE_CCV_READ) {
         $ppo->memos = $memoDAO->findByEleve($ppo->eleve, true);
     } else {
         $ppo->memos = $memoDAO->findByEleve(_currentUser()->getExtra('id'), true);
     }
     $toReturn = $this->_usePPO($ppo, '_memos.tpl');
 }
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:25,代码来源:memos.zone.php


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