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


PHP JDate::calendar方法代码示例

本文整理汇总了PHP中JDate::calendar方法的典型用法代码示例。如果您正苦于以下问题:PHP JDate::calendar方法的具体用法?PHP JDate::calendar怎么用?PHP JDate::calendar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JDate的用法示例。


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

示例1: calendar

 /**
  * Gets the date as a formatted string in a local calendar.
  *
  * @param   string   $format     The date format specification string (see {@link PHP_MANUAL#date})
  * @param   boolean  $local      True to return the date string in the local time zone, false to return it in GMT.
  * @param   boolean  $translate  True to translate localised strings
  *
  * @return  string   The date string in the specified format format.
  *
  * @since   11.1
  */
 public function calendar($format, $local = false, $translate = true)
 {
     // Do string replacements for date format options that can be translated.
     $format = preg_replace('/(^|[^\\\\])d/', "\\1" . self::DAY_NUMBER2, $format);
     $format = preg_replace('/(^|[^\\\\])j/', "\\1" . self::DAY_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])z/', "\\1" . self::DAY_YEAR, $format);
     $format = preg_replace('/(^|[^\\\\])M/', "\\1" . self::MONTH_ABBR, $format);
     $format = preg_replace('/(^|[^\\\\])F/', "\\1" . self::MONTH_NAME, $format);
     $format = preg_replace('/(^|[^\\\\])n/', "\\1" . self::MONTH_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])m/', "\\1" . self::MONTH_NUMBER2, $format);
     $format = preg_replace('/(^|[^\\\\])t/', "\\1" . self::MONTH_LENGTH, $format);
     $format = preg_replace('/(^|[^\\\\])y/', "\\1" . self::YEAR_ABBR, $format);
     $format = preg_replace('/(^|[^\\\\])Y/', "\\1" . self::YEAR_NAME, $format);
     $format = preg_replace('/(^|[^\\\\])a/', "\\1" . self::AM_LOWER, $format);
     $format = preg_replace('/(^|[^\\\\])A/', "\\1" . self::AM_UPPER, $format);
     // Format the date.
     $return = parent::calendar($format, $local);
     $jd = gregoriantojd($this->month, $this->day, $this->year);
     $lunarDate = self::jdtolunar($jd);
     $m = $lunarDate['mon'];
     $d = $lunarDate['day'];
     $y = $lunarDate['year'];
     // Manually modify the strings in the formated time.
     if (strpos($return, self::DAY_NUMBER) !== false) {
         $return = str_replace(self::DAY_NUMBER, $d, $return);
     }
     if (strpos($return, self::DAY_NUMBER2) !== false) {
         $return = str_replace(self::DAY_NUMBER2, sprintf("%02d", $d), $return);
     }
     if (strpos($return, self::DAY_YEAR) !== false) {
         $return = str_replace(self::DAY_YEAR, $jd - self::lunartojd(1, 1, $y) + 1, $return);
     }
     if (strpos($return, self::MONTH_ABBR) !== false) {
         $return = str_replace(self::MONTH_ABBR, $this->monthToString($m, true), $return);
     }
     if (strpos($return, self::MONTH_NAME) !== false) {
         $return = str_replace(self::MONTH_NAME, $this->monthToString($m), $return);
     }
     if (strpos($return, self::MONTH_NUMBER) !== false) {
         $return = str_replace(self::MONTH_NUMBER, $m, $return);
     }
     if (strpos($return, self::MONTH_NUMBER2) !== false) {
         $return = str_replace(self::MONTH_NUMBER2, sprintf("%02d", $m), $return);
     }
     if (strpos($return, self::MONTH_LENGTH) !== false) {
         $return = str_replace(self::MONTH_LENGTH, $m == 12 && self::leap_lunar($y) ? 30 : $m % 2 ? 30 : 29, $return);
     }
     if (strpos($return, self::YEAR_ABBR) !== false) {
         $return = str_replace(self::YEAR_ABBR, sprintf("%02d", $y % 100), $return);
     }
     if (strpos($return, self::YEAR_NAME) !== false) {
         $return = str_replace(self::YEAR_NAME, $y, $return);
     }
     if (strpos($return, self::AM_LOWER) !== false) {
         $return = str_replace(self::AM_LOWER, $this->format('a', $local) == 'pm' ? JText::_('PM_SHORT') : JText::_('AM_SHORT'), $return);
     }
     if (strpos($return, self::AM_UPPER) !== false) {
         $return = str_replace(self::AM_UPPER, $this->format('a', $local) == 'pm' ? JText::_('PM') : JText::_('AM'), $return);
     }
     return $return;
 }
开发者ID:abdullah929,项目名称:bulletin,代码行数:72,代码来源:helper.php

示例2: calendar

 public function calendar($format, $local = false, $translate = true)
 {
     // Do string replacements for date format options that can be translated.
     $format = preg_replace('/(^|[^\\\\])d/', "\\1" . self::DAY_NUMBER2, $format);
     $format = preg_replace('/(^|[^\\\\])j/', "\\1" . self::DAY_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])z/', "\\1" . self::DAY_YEAR, $format);
     $format = preg_replace('/(^|[^\\\\])M/', "\\1" . self::MONTH_ABBR, $format);
     $format = preg_replace('/(^|[^\\\\])F/', "\\1" . self::MONTH_NAME, $format);
     $format = preg_replace('/(^|[^\\\\])n/', "\\1" . self::MONTH_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])m/', "\\1" . self::MONTH_NUMBER2, $format);
     $format = preg_replace('/(^|[^\\\\])t/', "\\1" . self::MONTH_LENGTH, $format);
     $format = preg_replace('/(^|[^\\\\])y/', "\\1" . self::YEAR_ABBR, $format);
     $format = preg_replace('/(^|[^\\\\])Y/', "\\1" . self::YEAR_NAME, $format);
     $format = preg_replace('/(^|[^\\\\])a/', "\\1" . self::AM_LOWER, $format);
     $format = preg_replace('/(^|[^\\\\])A/', "\\1" . self::AM_UPPER, $format);
     // Format the date.
     $return = parent::calendar($format, $local);
     $jd = gregoriantojd($this->month, $this->day, $this->year);
     $jalaliDate = self::jd_to_persian($jd);
     $m = $jalaliDate['mon'];
     $d = $jalaliDate['day'];
     $y = $jalaliDate['year'];
     // Manually modify the strings in the formated time.
     if (strpos($return, self::DAY_NUMBER) !== false) {
         $return = str_replace(self::DAY_NUMBER, $d, $return);
     }
     if (strpos($return, self::DAY_NUMBER2) !== false) {
         $return = str_replace(self::DAY_NUMBER2, sprintf("%02d", $d), $return);
     }
     if (strpos($return, self::DAY_YEAR) !== false) {
         $return = str_replace(self::DAY_YEAR, $jd - self::persian_to_jd(1, 1, $y) + 1, $return);
     }
     if (strpos($return, self::MONTH_ABBR) !== false) {
         $return = str_replace(self::MONTH_ABBR, self::$month_names[$m - 1], $return);
     }
     if (strpos($return, self::MONTH_NAME) !== false) {
         $return = str_replace(self::MONTH_NAME, self::$month_names[$m - 1], $return);
     }
     if (strpos($return, self::MONTH_NUMBER) !== false) {
         $return = str_replace(self::MONTH_NUMBER, $m, $return);
     }
     if (strpos($return, self::MONTH_NUMBER2) !== false) {
         $return = str_replace(self::MONTH_NUMBER2, sprintf("%02d", $m), $return);
     }
     if (strpos($return, self::MONTH_LENGTH) !== false) {
         $return = str_replace(self::MONTH_LENGTH, $m < 7 ? 31 : $m < 12 ? 30 : self::leap_persian($y) ? 30 : 29, $return);
     }
     if (strpos($return, self::YEAR_ABBR) !== false) {
         $return = str_replace(self::YEAR_ABBR, sprintf("%02d", $y % 100), $return);
     }
     if (strpos($return, self::YEAR_NAME) !== false) {
         $return = str_replace(self::YEAR_NAME, $y, $return);
     }
     if (strpos($return, self::AM_LOWER) !== false) {
         $return = str_replace(self::AM_LOWER, $this->format('a', $local) == 'pm' ? 'ب ظ' : 'ق ظ', $return);
     }
     if (strpos($return, self::AM_UPPER) !== false) {
         $return = str_replace(self::AM_UPPER, $this->format('a', $local) == 'pm' ? 'ب ظ' : 'ق ظ', $return);
     }
     return $return;
 }
开发者ID:digimarketingteam,项目名称:Joomla,代码行数:61,代码来源:fa-IR.localise.php

示例3: die

<?php

/**
 * JBZoo App is universal Joomla CCK, application for YooTheme Zoo component
 *
 * @package     jbzoo
 * @version     2.x Pro
 * @author      JBZoo App http://jbzoo.com
 * @copyright   Copyright (C) JBZoo.com,  All rights reserved.
 * @license     http://jbzoo.com/license-pro.php JBZoo Licence
 * @coder       Alexander Oganov <t_tapak@yahoo.com>
 */
// no direct access
defined('_JEXEC') or die('Restricted access');
$date = new JDate($order->created);
echo $date->calendar($params->get('format', 'D, d M Y H:i'), false, true);
开发者ID:alexmixaylov,项目名称:real,代码行数:16,代码来源:created.php

示例4: calendar

 /**
  * Gets the date as a formatted string.
  *
  * @param	string	The date format specification string (see {@link PHP_MANUAL#date})
  * @param	boolean	True to return the date string in the local time zone, false to return it in GMT.
  * @return	string	The date string in the french republican calendar (see @link{http://en.wikipedia.org/wiki/French_Republican_Calendar}).
  * @since	1.6
  */
 public function calendar($format, $local = false, $translate = true)
 {
     // Do string replacements for date format options that can be translated.
     $format = preg_replace('/(^|[^\\\\])d/', "\\1" . self::DAY_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])m/', "\\1" . self::MONTH_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])Y/', "\\1" . self::YEAR_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])y/', "\\1" . self::YEAR_NUMBER2, $format);
     $format = preg_replace('/(^|[^\\\\])H/', "\\1" . self::HOUR_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])i/', "\\1" . self::MINUTE_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])s/', "\\1" . self::SECOND_NUMBER, $format);
     $format = preg_replace('/(^|[^\\\\])S/', "\\1" . self::ORDINAL_NUMBER, $format);
     // Format the date.
     $return = parent::calendar($format, $local);
     // convNumber : true = thai number , false = arabic number
     $convNumber = false;
     if (strpos($return, self::DAY_NUMBER) !== false) {
         $return = str_replace(self::DAY_NUMBER, $this->numToString($this->day, $convNumber), $return);
     }
     if (strpos($return, self::MONTH_NUMBER) !== false) {
         $return = str_replace(self::MONTH_NUMBER, $this->numToString($this->month, $convNumber), $return);
     }
     if (strpos($return, self::YEAR_NUMBER) !== false) {
         $return = str_replace(self::YEAR_NUMBER, $this->yearToString($this->year, $convNumber), $return);
     }
     if (strpos($return, self::YEAR_NUMBER2) !== false) {
         $return = str_replace(self::YEAR_NUMBER2, JString::substr($this->yearToString($this->year, $convNumber), -2), $return);
     }
     if (strpos($return, self::HOUR_NUMBER) !== false) {
         $return = str_replace(self::HOUR_NUMBER, $this->numToString($this->hour, $convNumber), $return);
     }
     if (strpos($return, self::MINUTE_NUMBER) !== false) {
         $return = str_replace(self::MINUTE_NUMBER, $this->numToString($this->minute, $convNumber), $return);
     }
     if (strpos($return, self::SECOND_NUMBER) !== false) {
         $return = str_replace(self::SECOND_NUMBER, $this->numToString($this->second, $convNumber), $return);
     }
     if (strpos($return, self::ORDINAL_NUMBER) !== false) {
         $return = str_replace(self::ORDINAL_NUMBER, $this->numToString($this->ordinal, $convNumber), $return);
     }
     return $return;
 }
开发者ID:paisit,项目名称:pyzid,代码行数:49,代码来源:th-TH.localise.php

示例5: dirname

require_once dirname(__FILE__) . '/helper.php';
$params->id = $module->id;
$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));
$items = $params->get('items');
foreach ($items as $item) {
    switch ($item) {
        case 'analog':
            $analog_clock = ModDateTimeHelper::getAnalogClock($params);
            break;
        case 'digital':
            $digital_clock = ModDateTimeHelper::getDigitalClock($params);
            break;
        case 'day':
            $offset = $params->get('offset', 'UTC');
            $today = new JDate('now', $offset);
            $day_name = $today->calendar('l', true);
            break;
        case 'timezone':
            $timezone = ModDateTimeHelper::getTimeZoneText($params);
            break;
        case 'gregorian':
            $gregorian_date = ModDateTimeHelper::getGregorianDate($params);
            break;
        case 'solar':
            $solar_date = ModDateTimeHelper::getSolarDate($params);
            break;
        case 'lunar':
            $lunar_date = ModDateTimeHelper::getLunarDate($params);
            break;
    }
}
开发者ID:abdullah929,项目名称:bulletin,代码行数:31,代码来源:mod_currentdatetime.php


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