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

PHP strftime函数代码示例

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

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



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

示例1: getDatesBetween

 public function getDatesBetween($dStart, $dEnd)
 {
     if ($dStart > $dEnd) {
         $var = $dStart;
         $dStart = $dEnd;
         $dEnd = $var;
     }
     $iStart = strtotime($dStart);
     $iEnd = strtotime($dEnd);
     if (false === $iStart || false === $iEnd) {
         return false;
     }
     $aStart = explode('-', $dStart);
     $aEnd = explode('-', $dEnd);
     if (count($aStart) !== 3 || count($aEnd) !== 3) {
         return false;
     }
     if (false === checkdate($aStart[1], $aStart[2], $aStart[0]) || false === checkdate($aEnd[1], $aEnd[2], $aEnd[0]) || $iEnd < $iStart) {
         return false;
     }
     for ($i = $iStart; $i < $iEnd + 86400; $i = strtotime('+1 day', $i)) {
         $sDateToArr = strftime('%Y-%m-%d', $i);
         $sYear = substr($sDateToArr, 0, 4);
         $sMonth = substr($sDateToArr, 5, 2);
         //$aDates[$sYear][$sMonth][]=$sDateToArr;
         $aDates[] = $sDateToArr;
     }
     if (isset($aDates) && !empty($aDates)) {
         return $aDates;
     } else {
         return false;
     }
 }
开发者ID:NadaNafti,项目名称:Thalassa,代码行数:33,代码来源:Library.php


示例2: write_log

function write_log()
{
    global $HTTP_RAW_POST_DATA;
    $fp = @fopen(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'xmlrpclog', 'a');
    if ($fp) {
        $lnsep = "\n================================\n";
        fwrite($fp, "\n{$lnsep}" . strftime("%Y-%m-%d %H:%M:%S"));
        fwrite($fp, '[USER_AGENT] ' . $_SERVER['HTTP_USER_AGENT']);
        fwrite($fp, $lnsep);
        fwrite($fp, '[ACCEPT_ENCODING] ' . $_SERVER['HTTP_ACCEPT_ENCODING']);
        if (strpos(strtolower($_SERVER['SERVER_SOFTWARE']), 'apache') !== false) {
            fwrite($fp, $lnsep);
            fwrite($fp, "Apache Request Headers:\n");
            fwrite($fp, $lnsep);
            $headers = getallheaders();
            foreach ($headers as $header => $value) {
                fwrite($fp, "{$header}: {$value} \n");
            }
        }
        fwrite($fp, $lnsep);
        fwrite($fp, "Incoming data, usually utf-8 encoded:\n");
        fwrite($fp, $lnsep);
        fwrite($fp, $HTTP_RAW_POST_DATA);
    }
    @fclose($fp);
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:26,代码来源:index.php


示例3: setup

 function setup()
 {
     $oRootFolder =& Folder::get(1);
     $this->oUser = User::get(1);
     $sName = 'PermissionsTrest' . strftime('%Y%m%d%H%M%S');
     $this->oFolder =& KTFolderUtil::add($oRootFolder, $sName, $this->oUser);
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:7,代码来源:testPermissions.php


示例4: ageToYear

 function ageToYear($age)
 {
     $currYear = strftime('%Y');
     $currMonthDate = strftime('-%m-%d');
     $birthYear = (int) $currYear - $age;
     return $birthYear . $currMonthDate;
 }
开发者ID:noikiy,项目名称:owaspbwa,代码行数:7,代码来源:ReportGenerator.php


示例5: getChanges

 public function getChanges(array $resourceArray)
 {
     $emptyDate = '0000-00-00 00:00:00';
     $resourceArray['pub_date'] = !empty($resourceArray['pub_date']) && $resourceArray['pub_date'] != $emptyDate ? $resourceArray['pub_date'] : $this->modx->lexicon('none');
     $resourceArray['unpub_date'] = !empty($resourceArray['unpub_date']) && $resourceArray['unpub_date'] != $emptyDate ? $resourceArray['unpub_date'] : $this->modx->lexicon('none');
     $resourceArray['status'] = $resourceArray['published'] ? $this->modx->lexicon('resource_published') : $this->modx->lexicon('resource_unpublished');
     $server_offset_time = intval($this->modx->getOption('server_offset_time', null, 0));
     $resourceArray['createdon_adjusted'] = strftime('%c', strtotime($this->resource->get('createdon')) + $server_offset_time);
     $resourceArray['createdon_by'] = $this->resource->get('creator');
     if (!empty($resourceArray['editedon']) && $resourceArray['editedon'] != $emptyDate) {
         $resourceArray['editedon_adjusted'] = strftime('%c', strtotime($this->resource->get('editedon')) + $server_offset_time);
         $resourceArray['editedon_by'] = $this->resource->get('editor');
     } else {
         $resourceArray['editedon_adjusted'] = $this->modx->lexicon('none');
         $resourceArray['editedon_by'] = $this->modx->lexicon('none');
     }
     if (!empty($resourceArray['publishedon']) && $resourceArray['publishedon'] != $emptyDate) {
         $resourceArray['publishedon_adjusted'] = strftime('%c', strtotime($this->resource->get('editedon')) + $server_offset_time);
         $resourceArray['publishedon_by'] = $this->resource->get('publisher');
     } else {
         $resourceArray['publishedon_adjusted'] = $this->modx->lexicon('none');
         $resourceArray['publishedon_by'] = $this->modx->lexicon('none');
     }
     return $resourceArray;
 }
开发者ID:nervlin4444,项目名称:modx-cms,代码行数:25,代码来源:data.class.php


示例6: format

 public static function format($time)
 {
     $out = '';
     // what we will print out
     $now = time();
     // current time
     $diff = $now - $time;
     // difference between the current and the provided dates
     if ($diff < 60) {
         // it happened now
         return TIMEBEFORE_NOW;
     } elseif ($diff < 3600) {
         // it happened X minutes ago
         return str_replace('{num}', $out = round($diff / 60), $out == 1 ? TIMEBEFORE_MINUTE : TIMEBEFORE_MINUTES);
     } elseif ($diff < 3600 * 24) {
         // it happened X hours ago
         return str_replace('{num}', $out = round($diff / 3600), $out == 1 ? TIMEBEFORE_HOUR : TIMEBEFORE_HOURS);
     } elseif ($diff < 3600 * 24 * 2) {
         // it happened yesterday
         return TIMEBEFORE_YESTERDAY;
     } else {
         // falling back on a usual date format as it happened later than yesterday
         return strftime(date('Y', $time) == date('Y') ? TIMEBEFORE_FORMAT : TIMEBEFORE_FORMAT_YEAR, $time);
     }
 }
开发者ID:9illes,项目名称:timeline-php,代码行数:25,代码来源:TimeAgo.php


示例7: get

 function get()
 {
     global $I18N;
     // getId() ist erst hier verfügbar
     $this->addConfig('inputField', 'label_' . $this->getId(), true);
     $this->addConfig('ifFormat', $I18N->msg('dateformat'), true);
     $this->addConfig('hiddenField', $this->getId(), true);
     $this->addConfig('button', 'trigger_' . $this->getId(), true);
     $this->addConfig('onUpdate', 'rex_a22_timestamp_from_calendar');
     $value = $this->getValue();
     $formattedValue = $value != '' ? strftime($I18N->msg('dateformat'), $value) : '';
     // Textfield für die formatierte Anzeige
     $s = parent::get();
     $s = str_replace('id="', 'id="label_', $s);
     $s = preg_replace('/name="[^"]*"/', '', $s);
     $s = preg_replace('/value="[^"]*"/', 'value="' . $formattedValue . '"', $s);
     $s .= "\n";
     // hidden field für das speichern des timestamps
     $s .= '<input type="hidden" id="' . $this->getId() . '" name="' . $this->getName() . '" value="' . $value . '" />' . "\n";
     $s .= '<button id="trigger_' . $this->getId() . '" style="background-image:url(' . $this->path . 'icons/calendar_edit.png); width: 16px; height: 20px; background-position: center; background-repeat: no-repeat;" title="Datum wählen"></button>';
     // Kalender setup
     $s .= '<script type="text/javascript">' . "\n";
     $s .= 'Calendar.setup({' . "\n";
     foreach ($this->getConfig() as $name => $value) {
         $s .= sprintf('  %-20s: %s,' . "\n", $name, $value);
     }
     $s .= '});' . "\n";
     $s .= '</script>' . "\n";
     return $s;
 }
开发者ID:BackupTheBerlios,项目名称:redaxo-addons,代码行数:30,代码来源:field.wysiwygDateField.inc.php


示例8: processSvn2RssRequest

 /**
  * Starts the processing of the current rss-request.
  * Acts like some kind of a main-method, so manages the further control-flow.
  */
 public function processSvn2RssRequest($strFeedParam = "")
 {
     try {
         //start by loading the config-file
         $objConfig = new ConfigReader($strFeedParam);
         //create the svn-reader and pass control
         $objSvnReader = new SvnReader($objConfig);
         $strSvnLog = $objSvnReader->getSvnLogContent();
         //create rss-nodes out of the logfile
         $objRssConverter = new Log2RssConverter($objConfig);
         $objRssRootNode = $objRssConverter->generateRssNodesFromLogContent($strSvnLog);
         $this->strOutput = $objRssRootNode->asXML();
     } catch (Svn2RssException $objException) {
         //Wrap error-message as a rss-feed element, too
         $objFeedRootNode = new SimpleXMLElement("<rss version=\"2.0\"></rss>");
         $objChannel = $objFeedRootNode->addChild("channel");
         $objChannel->addChild("title", "Error");
         $objChannel->addChild("description", "Error while loading feed");
         $objChannel->addChild("link", "n.a.");
         $objChannel->addChild("pubDate", strftime("%a, %d %b %Y %H:%M:%S GMT", time()));
         $objRssItemNode = $objChannel->addChild("item");
         $objRssItemNode->addChild("title", "Something bad happened: \n" . $objException->getMessage() . "");
         $objRssItemNode->addChild("description", "Something bad happened: \n" . $objException->getMessage() . "");
         $objRssItemNode->addChild("pubDate", strftime("%a, %d %b %Y %H:%M:%S GMT", time()));
         $this->strOutput = $objFeedRootNode->asXML();
     }
 }
开发者ID:rcappuccio,项目名称:gitsvn,代码行数:31,代码来源:Svn2Rss.php


示例9: execute

 public function execute($language, $start = 0, $limit = 100)
 {
     $db = JFactory::getDBO();
     $source = $this->getCode();
     $query = $db->getQuery(true);
     $query->select('c.*');
     $query->from($db->quoteName($this->tableName) . ' AS c');
     $query->select('u.username as user_username, u.name as user_name, u.email as user_email');
     $query->join('LEFT', $db->quoteName('#__users') . ' AS u ON c.userid = u.id');
     $query->order($db->escape('c.time'));
     $db->setQuery($query, $start, $limit);
     $rows = $db->loadObjectList();
     foreach ($rows as $row) {
         $table = JTable::getInstance('Comment', 'JCommentsTable');
         $table->object_id = $row->product_id;
         $table->object_group = 'com_virtuemart';
         $table->parent = 0;
         $table->userid = $row->userid;
         $table->name = $row->name;
         $table->username = $row->username;
         $table->comment = $row->comment;
         $table->email = $row->email;
         $table->published = $row->published;
         $table->date = strftime("%Y-%m-%d %H:%M:00", $row->time);
         $table->lang = $language;
         $table->source = $source;
         $table->store();
     }
 }
开发者ID:ForAEdesWeb,项目名称:AEW2,代码行数:29,代码来源:virtuemart.php


示例10: convert_bdate

function convert_bdate($val, $month_fmt)
{
    $ret['year'] = substr($val, 0, 4);
    $ret['day'] = substr($val, 6, 2);
    $ret['month'] = strftime($month_fmt, mktime(1, 1, 1, substr($val, 4, 2), 11, 2000));
    return $ret;
}
开发者ID:BackupTheBerlios,项目名称:milaninegw-svn,代码行数:7,代码来源:usrinfo.php


示例11: log

 protected function log($time, $message, $logLevel, $logGroup, $ip, $file, $line, $type = null)
 {
     if ($message == "") {
         return;
     }
     $timeString = strftime("Y-m-d H:i:s", $time);
     $userId = null;
     try {
         $userId = Gpf_Session::getAuthUser()->getUserId();
     } catch (Gpf_Exception $e) {
     }
     try {
         $dbLog = new Gpf_Db_Log();
         $dbLog->set('groupid', $logGroup);
         $dbLog->set('level', $logLevel);
         $dbLog->set('created', $timeString);
         $dbLog->set('filename', $file);
         $dbLog->set('message', $message);
         $dbLog->set('line', $line);
         $dbLog->set('ip', $ip);
         $dbLog->set('accountuserid', $userId);
         $dbLog->set(Gpf_Db_Table_Logs::TYPE, $type);
         $dbLog->save();
     } catch (Exception $e) {
         Gpf_Log::disableType(Gpf_Log_LoggerDatabase::TYPE);
         Gpf_Log::error($this->_sys("Database Logger Error. Logging on display: %s", $message));
         Gpf_Log::enableAllTypes();
     }
 }
开发者ID:AmineCherrai,项目名称:rostanvo,代码行数:29,代码来源:LoggerDatabase.class.php


示例12: createTimeDimension

 public function createTimeDimension()
 {
     $this->out("helo");
     $this->loadModel('OlapTimeDimension');
     $month = date("n");
     $day = date("j");
     $year = date("Y");
     $minute = 0;
     $ts = mktime(0, $minute, 0, $month, $day, $year);
     $t = explode('/', strftime('%M/%H/%w/%d/%j/%m/%Y', $ts));
     $inputarr['OlapTimeDimension'] = array('id' => $ts, 'Minute' => $t[0], 'Hour' => $t[1], 'DayOfWeek' => $t[2], 'DayOfMonth' => $t[3], 'DayOfYear' => $t[4], 'Month' => $t[5], 'Quarter' => ceil($t[5] / 4), 'Year' => $t[6], 'Holiday' => in_array($t[2], array(0, 6)), 'Weekend' => in_array($t[2], array(0, 6)));
     $count = $this->OlapTimeDimension->find('count', array('conditions' => array('OlapTimeDimension.DayOfMonth' => $inputarr['OlapTimeDimension']['DayOfMonth'], 'OlapTimeDimension.Month' => $inputarr['OlapTimeDimension']['Month'], 'OlapTimeDimension.Year' => $inputarr['OlapTimeDimension']['Year'])));
     if ($count == 0) {
         $this->out('menjalankan perulangan hari');
         $tempDayOfYear = $inputarr['OlapTimeDimension']['DayOfYear'];
         while ($tempDayOfYear == $inputarr['OlapTimeDimension']['DayOfYear']) {
             $ts = mktime(0, $minute, 0, $month, $day, $year);
             $t = explode('/', strftime('%M/%H/%w/%d/%j/%m/%Y', $ts));
             $inputarr['OlapTimeDimension'] = array('id' => $ts, 'Minute' => $t[0], 'Hour' => $t[1], 'DayOfWeek' => $t[2], 'DayOfMonth' => $t[3], 'DayOfYear' => $t[4], 'Month' => $t[5], 'Quarter' => ceil($t[5] / 4), 'Year' => $t[6], 'Holiday' => in_array($t[2], array(0, 6)), 'Weekend' => in_array($t[2], array(0, 6)));
             if ($tempDayOfYear == $inputarr['OlapTimeDimension']['DayOfYear']) {
                 $this->OlapTimeDimension->set($inputarr);
                 $this->OlapTimeDimension->create();
                 $this->OlapTimeDimension->save($inputarr);
                 $minute += 5;
                 $this->out("menyimpan id " . $inputarr['OlapTimeDimension']['id']);
             }
         }
     }
 }
开发者ID:koprals,项目名称:coda-gosales-hsbc,代码行数:29,代码来源:OlapShell.php


示例13: getEventList

 /**
  * Get event list
  *
  * @param $events
  *
  * @return string
  */
 protected function getEventList($events)
 {
     $items = [];
     foreach ($events as $event) {
         $startDateStamp = $event['start_date'] instanceof \DateTime ? $event['start_date']->getTimestamp() : $event['start_date'];
         $startDate = strftime('%a %d.%m.%G', $startDateStamp);
         $endDateStamp = $event['end_date'] instanceof \DateTime ? $event['end_date']->getTimestamp() : $event['end_date'];
         $endDate = strftime('%a %d.%m.%G', $endDateStamp);
         $entry = $startDate . ' - ' . $endDate;
         if (!$event['all_day']) {
             $start = BackendUtility::time($event['start_time'], false);
             if ((int) $event['end_time'] === AbstractTimeTable::DAY_END) {
                 $end = '"' . TranslateUtility::get('openEndTime') . '"';
             } else {
                 $end = BackendUtility::time($event['end_time'], false);
             }
             $entry .= ' (' . $start . ' - ' . $end . ')';
         }
         $items[] = $entry;
     }
     if (!sizeof($items)) {
         $items[] = TranslateUtility::get('noEvents');
     }
     return '<ul><li>' . implode('</li><li>', $items) . '</li></ul>';
 }
开发者ID:mkalus,项目名称:calendarize,代码行数:32,代码来源:TcaInformation.php


示例14: comment_mail_notification

    public function comment_mail_notification()
    {
        $mail = new PHPMailer();
        $mail->isSMTP();
        $mail->Host = SMTP_HOST;
        $mail->SMTPAuth = SMTP_AUTH;
        $mail->Username = SMTP_USER;
        $mail->Password = SMTP_PASS;
        $mail->SMTPSecure = SMTP_SECURE;
        $mail->Port = SMTP_PORT;
        $mail->From = SMTP_FROM;
        $mail->FromName = SMTP_FROM_NAME;
        $mail->addReplyTo(SMTP_REPLY_TO, SMTP_REPLY_TO_NAME);
        $mail->addAddress(SMTP_TO, SMTP_TO_NAME);
        $mail->isHTML(SMTP_ISHTML);
        $mail->Subject = SMTP_SUBJECT . strftime("%T", time());
        $created = datetime_to_text($this->created);
        $mail_body = nl2br($this->body);
        $photo = Photograph::find_by_id($_GET['id']);
        $mail->Body = <<<EMAILBODY

A new comment has been received in the Photo Gallery.<br>
<br>
Photograph: {$photo->filename}<br>
<br>
On {$created}, {$this->author} wrote:<br>
<br>
{$mail_body}<br>

EMAILBODY;
        $result = $mail->send();
        return $result;
    }
开发者ID:Keav,项目名称:btbsandbox,代码行数:33,代码来源:comment.php


示例15: getEscapedValue

 public function getEscapedValue($index = null)
 {
     if ($this->getFormat() && $this->getValue()) {
         return strftime($this->getFormat(), strtotime($this->getValue()));
     }
     return htmlspecialchars($this->getValue());
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:7,代码来源:Date.php


示例16: init

 public function init($serie, $proprio)
 {
     $this->date = strftime('%e %B %G, %H:%M:%S');
     $this->serie = $serie;
     $this->proprio = $proprio;
     $this->reload_conf(0);
 }
开发者ID:bontiv,项目名称:intrateb,代码行数:7,代码来源:genserie.php


示例17: getTill

 public function getTill($format = null)
 {
     if ($format) {
         return strftime($format, strtotime($this->_till));
     }
     return $this->_till;
 }
开发者ID:sonvq,项目名称:2015_freelance6,代码行数:7,代码来源:Events.php


示例18: format_datetime

 function format_datetime($date = 'now')
 {
     if ($date == NULL) {
         return '';
     }
     return strftime("%A %e %B %Y, om %R uur", strtotime($date));
 }
开发者ID:UiL-OTS-labs,项目名称:babylab-admin,代码行数:7,代码来源:MY_date_helper.php


示例19: localeDateTime

 /**
  * Returns the date time in a particular format. Takes the locale into
  * account.
  *
  * @param string|\DateTime $dateTime
  * @param string           $format
  *
  * @return string Formatted date and time
  */
 public function localeDateTime($dateTime, $format = '%B %e, %Y %H:%M')
 {
     if (!$dateTime instanceof \DateTime) {
         $dateTime = new \DateTime($dateTime);
     }
     // Check for Windows to find and replace the %e modifier correctly
     // @see: http://php.net/strftime
     if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
         $format = preg_replace('#(?<!%)((?:%%)*)%e#', '\\1%#d', $format);
     }
     // According to http://php.net/manual/en/function.setlocale.php manual
     // if the second parameter is "0", the locale setting is not affected,
     // only the current setting is returned.
     $result = setlocale(LC_ALL, 0);
     if ($result === false) {
         // This shouldn't occur, but.. Dude!
         // You ain't even got locale or English on your platform??
         // Various things we could do. We could fail miserably, but a more
         // graceful approach is to use the datetime to display a default
         // format
         $this->app['logger.system']->error('No valid locale detected. Fallback on DateTime active.', ['event' => 'system']);
         return $dateTime->format('Y-m-d H:i:s');
     } else {
         $timestamp = $dateTime->getTimestamp();
         return strftime($format, $timestamp);
     }
 }
开发者ID:nuffer,项目名称:bolt,代码行数:36,代码来源:TextHandler.php


示例20: addClassOpen

 /**
  * Adds class phpdoc comment and openning of class.
  * @param      string &$script The script will be modified in this method.
  */
 protected function addClassOpen(&$script)
 {
     $table = $this->getTable();
     $this->declareClassFromBuilder($this->getPeerBuilder());
     $tableName = $table->getName();
     $tableDesc = $table->getDescription();
     switch ($table->treeMode()) {
         case 'NestedSet':
             $baseClassname = $this->getNestedSetPeerBuilder()->getClassname();
             break;
         case 'MaterializedPath':
         case 'AdjacencyList':
         default:
             $baseClassname = $this->getPeerBuilder()->getClassname();
             break;
     }
     if ($this->getBuildProperty('addClassLevelComment')) {
         $script .= "\r\n\r\n/**\r\n * Skeleton subclass for performing query and update operations on the '{$tableName}' table.\r\n *\r\n * {$tableDesc}\r\n *";
         if ($this->getBuildProperty('addTimeStamp')) {
             $now = strftime('%c');
             $script .= "\r\n * This class was autogenerated by Propel " . $this->getBuildProperty('version') . " on:\r\n *\r\n * {$now}\r\n *";
         }
         $script .= "\r\n * You should add additional methods to this class to meet the\r\n * application requirements.  This class will only be generated as\r\n * long as it does not already exist in the output directory.\r\n *\r\n * @package    propel.generator." . $this->getPackage() . "\r\n */";
     }
     $script .= "\r\nclass " . $this->getClassname() . " extends {$baseClassname}\r\n{";
 }
开发者ID:kcornejo,项目名称:estadistica,代码行数:30,代码来源:PHP5ExtensionPeerBuilder.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP strgen函数代码示例发布时间:2022-05-23
下一篇:
PHP strfrom函数代码示例发布时间: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