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


PHP Date::parse方法代码示例

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


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

示例1: fetchFromParameters

 public static function fetchFromParameters($params)
 {
     $roomPricePlan = new RoomPricePlan();
     if (isset($params['id']) && is_numeric($params['id'])) {
         $roomPricePlan->id = intval($params['id']);
     }
     if (isset($params['room_id'])) {
         $roomPricePlan->roomId = intval($params['room_id']);
     }
     if (isset($params['start_date'])) {
         $roomPricePlan->startDate = Date::parse($params['start_date']);
     }
     if (isset($params['end_date'])) {
         $roomPricePlan->endDate = Date::parse($params['end_date']);
     }
     if (isset($params['price'])) {
         $roomPricePlan->price = floatval($params['price']);
     }
     if (isset($params['extrabed'])) {
         $roomPricePlan->extraBedPrice = floatval($params['extrabed']);
     }
     if (isset($params['default_plan'])) {
         $roomPricePlan->isDefault = intval($params['default_plan']) == 1;
     }
     return $roomPricePlan;
 }
开发者ID:earthtravels,项目名称:maxtena,代码行数:26,代码来源:RoomPricePlan.class.php

示例2: parseCity

 protected function parseCity($objAirQualityCity, $blnAddArchive = false, $strClass = '', $intCount = 0)
 {
     /** @var \PageModel $objPage */
     global $objPage;
     $objTemplate->setData($objAirQualityCity->row());
     $this->Template->date = \Date::parse('l j F');
 }
开发者ID:respinar,项目名称:contao-airquality,代码行数:7,代码来源:ModuleAirQuality.php

示例3: compile

 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $arrJumpTo = array();
     $arrNewsletter = array();
     $strRequest = ampersand(\Environment::get('request'), true);
     $objNewsletter = \NewsletterModel::findSentByPids($this->nl_channels);
     if ($objNewsletter !== null) {
         while ($objNewsletter->next()) {
             if (($objTarget = $objNewsletter->getRelated('pid')) === null) {
                 continue;
             }
             $jumpTo = intval($objTarget->jumpTo);
             // A jumpTo page is not mandatory for newsletter channels (see #6521) but required for the list module
             if ($jumpTo < 1) {
                 throw new \Exception("Newsletter channels without redirect page cannot be used in a newsletter list");
             }
             $strUrl = $strRequest;
             if (!isset($arrJumpTo[$objTarget->jumpTo])) {
                 $objJumpTo = $objTarget->getRelated('jumpTo')->loadDetails();
                 if ($objJumpTo !== null) {
                     $arrJumpTo[$objTarget->jumpTo] = $this->generateFrontendUrl($objJumpTo->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s');
                 } else {
                     $arrJumpTo[$objTarget->jumpTo] = $strUrl;
                 }
             }
             $strUrl = $arrJumpTo[$objTarget->jumpTo];
             $strAlias = $objNewsletter->alias != '' && !\Config::get('disableAlias') ? $objNewsletter->alias : $objNewsletter->id;
             $arrNewsletter[] = array('subject' => $objNewsletter->subject, 'title' => strip_insert_tags($objNewsletter->subject), 'href' => sprintf($strUrl, $strAlias), 'date' => \Date::parse($objPage->dateFormat, $objNewsletter->date), 'datim' => \Date::parse($objPage->datimFormat, $objNewsletter->date), 'time' => \Date::parse($objPage->timeFormat, $objNewsletter->date), 'channel' => $objNewsletter->channel);
         }
     }
     $this->Template->newsletters = $arrNewsletter;
 }
开发者ID:iCodr8,项目名称:core,代码行数:36,代码来源:ModuleNewsletterList.php

示例4: getMetaFields

 /**
  * Return the meta fields of a news article as array
  * @param object
  * @return array
  */
 public static function getMetaFields($objModule, $objArticle)
 {
     $meta = deserialize($objModule->news_metaFields);
     if (!is_array($meta)) {
         return array();
     }
     global $objPage;
     $return = array();
     foreach ($meta as $field) {
         switch ($field) {
             case 'date':
                 $return['date'] = \Date::parse($objPage->datimFormat, $objArticle->date);
                 break;
             case 'author':
                 if (($objAuthor = $objArticle->getRelated('author')) !== null) {
                     if ($objAuthor->google != '') {
                         $return['author'] = $GLOBALS['TL_LANG']['MSC']['by'] . ' <a href="https://plus.google.com/' . $objAuthor->google . '" rel="author" target="_blank">' . $objAuthor->name . '</a>';
                     } else {
                         $return['author'] = $GLOBALS['TL_LANG']['MSC']['by'] . ' ' . $objAuthor->name;
                     }
                 }
                 break;
             case 'comments':
                 if ($objArticle->noComments || $objArticle->source != 'default') {
                     break;
                 }
                 $intTotal = \CommentsModel::countPublishedBySourceAndParent('tl_news', $objArticle->id);
                 $return['ccount'] = $intTotal;
                 $return['comments'] = sprintf($GLOBALS['TL_LANG']['MSC']['commentCount'], $intTotal);
                 break;
         }
     }
     return $return;
 }
开发者ID:heimrichhannot,项目名称:contao-formhybrid_list,代码行数:39,代码来源:ModuleNews.php

示例5: addSystemMessages

 public function addSystemMessages()
 {
     $objUser = \BackendUser::getInstance();
     if ($GLOBALS['TL_CONFIG']['be_changelog_src'] == '') {
         return '';
     }
     $strFile = file_get_contents($GLOBALS['TL_CONFIG']['be_changelog_src']);
     if ($strFile == '') {
         return '';
     }
     $objJson = json_decode($strFile);
     $objTemplate = new \BackendTemplate('be_changelog');
     $objTemplate->strTitle = 'Changelog';
     $arrEntries = array();
     foreach ($objJson as $objEntry) {
         $objTemplateEntry = new \BackendTemplate('be_changelog_entry');
         $objTemplateEntry->strCssClass = $objUser->lastLogin > $objEntry->timestamp ? '' : ' tl_info';
         $objTemplateEntry->strDate = \Date::parse(\Config::get('datimFormat'), $objEntry->timestamp);
         $objTemplateEntry->strVersion = $objEntry->version;
         $objTemplateEntry->strEntries = '<li style="padding-bottom: 5px;">' . implode('</li><li style="padding-bottom: 5px;">', $objEntry->entries) . '</li>';
         $arrEntries[$objEntry->timestamp] = $objTemplateEntry->parse();
     }
     krsort($arrEntries);
     $objTemplate->strEntries = implode('', $arrEntries);
     return $objTemplate->parse();
 }
开发者ID:mindbird,项目名称:contao-be-changelog,代码行数:26,代码来源:BeChangelog.php

示例6: compile

 /**
  * Compile the current element
  */
 protected function compile()
 {
     $arrResult = array();
     foreach ($this->arrLog as $key => $data) {
         $tstamp = \Date::parse("Y-m-d", $data['tstamp']);
         if (!isset($arrResult[$tstamp])) {
             $arrResult[$tstamp] = $this->arrAction;
         }
         $arrResult[$tstamp]['date'] = $tstamp;
         $arrResult[$tstamp]['tstamp'] = $data['tstamp'];
         $arrResult[$tstamp][strtolower($data['action'])] += 1;
     }
     $arrData = array();
     foreach ($arrResult as $value) {
         $arrData[] = $value;
     }
     $arrAction = array_keys($this->arrAction);
     $arrColor = $this->getColorArray($arrAction);
     $arrLabels = $arrAction;
     $arrLabels = array_map("ucfirst", $arrLabels);
     $this->Template->inputAction = $arrAction;
     $this->Template->inputLabel = $arrLabels;
     $this->Template->inputLabelColor = $arrColor;
     $this->Template->data = json_encode($arrData);
     $this->Template->yKeys = "['" . implode("','", $arrAction) . "']";
     $this->Template->labels = "['" . implode("','", $arrLabels) . "']";
     $this->Template->lineColors = "['" . implode("','", $arrColor) . "']";
     $this->Template->xKey = "date";
     $this->Template->headline = $GLOBALS['TL_LANG']['MOD']['log'][0];
 }
开发者ID:zeromax,项目名称:contao-sb-admin,代码行数:33,代码来源:LogChart.php

示例7: listNewsletterArticles

    /**
     * Add the type of input field
     * @param array
     * @return string
     */
    public function listNewsletterArticles($arrRow)
    {
        $strStats = '';
        $strContents = '';
        $objContents = \ContentModel::findPublishedByPidAndTable($arrRow['id'], 'tl_newsletter');
        if (!is_null($objContents)) {
            foreach ($objContents as $objContent) {
                $strContents .= $this->getContentElement($objContent->id) . '<hr>';
            }
        }
        $intTotal = $arrRow['recipients'] + $arrRow['rejected'];
        //		$intTracked = NewsletterContent\Models\NewsletterTrackingModel::countTrackedByPid($arrRow['id']);
        $objTracked = NewsletterContent\Models\NewsletterTrackingModel::findTrackedInteractionsByPid($arrRow['id']);
        $intTracked = !is_null($objTracked) ? $objTracked->count() : 0;
        $intPercent = @round($intTracked / $intTotal * 100);
        $strStats = sprintf($GLOBALS['TL_LANG']['tl_newsletter']['sentTo'], $arrRow['recipients'], strval($intTotal), strval($intTracked), strval($intPercent));
        return '
<div class="cte_type ' . ($arrRow['sent'] && $arrRow['date'] ? 'published' : 'unpublished') . '"><strong>' . $arrRow['subject'] . '</strong> - ' . ($arrRow['sent'] && $arrRow['date'] ? sprintf($GLOBALS['TL_LANG']['tl_newsletter']['sentOn'], Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $arrRow['date'])) . '<br>' . $strStats : $GLOBALS['TL_LANG']['tl_newsletter']['notSent']) . '</div>
<div class="limit_height' . (!$GLOBALS['TL_CONFIG']['doNotCollapse'] ? ' h128' : '') . '">
' . (!$arrRow['sendText'] && strlen($strContents) ? '
' . $strContents : '') . '
' . nl2br_html5($arrRow['text']) . '
</div>' . "\n";
        return '<div class="tl_content_left">' . $arrRow['subject'] . ' <span style="color:#b3b3b3;padding-left:3px">[' . $arrRow['senderName'] . ' &lt;' . $arrRow['sender'] . '&gt;]</span></div>';
    }
开发者ID:davidenke,项目名称:newsletter_content,代码行数:30,代码来源:tl_newsletter.php

示例8: prepareLabel

 /**
  * Get the label for a form value to store in lead table.
  *
  * @param mixed $varValue
  * @param \Database\Result $objField
  *
  * @return mixed
  */
 public static function prepareLabel($varValue, $objField)
 {
     // Run for all values in an array
     if (is_array($varValue)) {
         foreach ($varValue as $k => $v) {
             $varValue[$k] = self::prepareLabel($v, $objField);
         }
         return $varValue;
     }
     // File upload
     if ($objField->type == 'upload') {
         $objFile = \FilesModel::findByUuid($varValue);
         if ($objFile !== null) {
             return $objFile->path;
         }
     }
     // Convert timestamps into date format
     if ($varValue != '' && in_array($objField->rgxp, array('date', 'time', 'datim'))) {
         $varValue = \Date::parse($GLOBALS['TL_CONFIG'][$objField->rgxp . 'Format'], $varValue);
     }
     if ($objField->options != '') {
         $arrOptions = deserialize($objField->options, true);
         foreach ($arrOptions as $arrOption) {
             if ($arrOption['value'] == $varValue && $arrOption['label'] != '') {
                 $varValue = $arrOption['label'];
             }
         }
     }
     return $varValue;
 }
开发者ID:terminal42,项目名称:contao-leads,代码行数:38,代码来源:Leads.php

示例9: formatsByConfigFormat

 private function formatsByConfigFormat($format)
 {
     $const = get_called_class() . '::' . strtoupper($format) . '_FORMAT';
     $tstamp = time();
     $expected = \Date::parse(constant($const), $tstamp);
     $definition['eval']['rgxp'] = $format;
     $this->format($tstamp, $format, $definition)->shouldReturn($expected);
 }
开发者ID:netzmacht,项目名称:contao-toolkit,代码行数:8,代码来源:DateFormatterSpec.php

示例10: lastLogin

 /**
  * Return the date of the last login
  *
  * @return string
  */
 public function lastLogin()
 {
     $this->import('BackendUser', 'User');
     if ($this->User->lastLogin > 0) {
         return '<p class="tl_info">' . sprintf($GLOBALS['TL_LANG']['MSC']['lastLogin'][1], \Date::parse(\Config::get('datimFormat'), $this->User->lastLogin)) . '</p>';
     }
     return '';
 }
开发者ID:Mozan,项目名称:core-bundle,代码行数:13,代码来源:Messages.php

示例11: transform

 public static function transform($varValue, $strField, $arrParams, \HeimrichHannot\Submissions\SubmissionModel $objSubmission)
 {
     switch ($arrParams[0]) {
         case 'date':
             $varValue = \Date::parse($arrParams[1], $varValue);
             break;
     }
     return $varValue;
 }
开发者ID:heimrichhannot,项目名称:contao-submissions,代码行数:9,代码来源:Tokens.php

示例12: fetchFromParameters

 public static function fetchFromParameters($params, $isDatabaseRow = false)
 {
     NewsPost::$staticErrors = array();
     $newsPost = new NewsPost();
     if (isset($params['id']) && is_numeric($params['id'])) {
         $newsPost->id = intval($params['id']);
     }
     if (isset($params['category_id']) && is_numeric($params['category_id'])) {
         $newsPost->categoryId = intval($params['category_id']);
     }
     $newsPost->title = LocalizedText::fetchFromParameters($params, NewsPost::$titlePrefix);
     $newsPost->contents = LocalizedText::fetchFromParameters($params, NewsPost::$contentsPrefix);
     if ($isDatabaseRow && isset($params['image_small'])) {
         $newsPost->imageSmall = $params['image_small'];
     } else {
         if (!$isDatabaseRow && isset($_FILES['image_small']['name']) && trim($_FILES['image_small']['name']) != "") {
             $imageName = NULL;
             if (!UploadImage::upload($_FILES, "image_small", "../images", $imageName)) {
                 NewsPost::$staticErrors = UploadImage::$errors;
                 return null;
             }
             $newsPost->imageSmall = $imageName;
         }
     }
     if ($isDatabaseRow && isset($params['image_medium'])) {
         $newsPost->imageMedium = $params['image_medium'];
     } else {
         if (!$isDatabaseRow && isset($_FILES['image_medium']['name']) && trim($_FILES['image_medium']['name']) != "") {
             $imageName = NULL;
             if (!UploadImage::upload($_FILES, "image_medium", "../images", $imageName)) {
                 NewsPost::$staticErrors = UploadImage::$errors;
                 return null;
             }
             $newsPost->imageMedium = $imageName;
         }
     }
     if ($isDatabaseRow && isset($params['image_large'])) {
         $newsPost->imageLarge = $params['image_large'];
     } else {
         if (!$isDatabaseRow && isset($_FILES['image_large']['name']) && trim($_FILES['image_large']['name']) != "") {
             $imageName = NULL;
             if (!UploadImage::upload($_FILES, "image_large", "../images", $imageName)) {
                 NewsPost::$staticErrors = UploadImage::$errors;
                 return null;
             }
             $newsPost->imageLarge = $imageName;
         }
     }
     if (isset($params['poster_name'])) {
         $newsPost->posterName = trim($params['poster_name']);
     }
     if (isset($params['date_posted'])) {
         $newsPost->postedDate = Date::parse(trim($params['date_posted']));
     }
     return $newsPost;
 }
开发者ID:earthtravels,项目名称:maxtena,代码行数:56,代码来源:NewsPost.class.php

示例13: format

 /**
  * {@inheritDoc}
  */
 public function format($value, $fieldName, array $fieldDefinition, $context = null)
 {
     if (empty($fieldDefinition['eval']['rgxp'])) {
         $format = 'datim';
     } else {
         $format = $fieldDefinition['eval']['rgxp'];
     }
     $dateFormat = $this->config->get($format . 'Format');
     return \Date::parse($dateFormat, $value);
 }
开发者ID:netzmacht,项目名称:contao-toolkit,代码行数:13,代码来源:DateFormatter.php

示例14: listChildren

 public function listChildren($arrRow)
 {
     $strTitle = $arrRow['id'];
     if (($objSubmission = \HeimrichHannot\Submissions\SubmissionModel::findByPk($arrRow['id'])) !== null && ($objSubmissionArchive = $objSubmission->getRelated('pid')) !== null) {
         $strTitle = preg_replace_callback('@%([^%]+)%@i', function ($arrMatches) use($objSubmission) {
             return $objSubmission->{$arrMatches[1]};
         }, $objSubmissionArchive->titlePattern);
     }
     return '<div class="tl_content_left">' . $strTitle . ' <span style="color:#b3b3b3; padding-left:3px">[' . \Date::parse(\Config::get('datimFormat'), trim($arrRow['dateAdded'])) . ']</span></div>';
 }
开发者ID:heimrichhannot,项目名称:contao-submissions,代码行数:10,代码来源:SubmissionBackend.php

示例15: listQuestions

    /**
     * Add the type of input field
     *
     * @param array $arrRow
     *
     * @return string
     */
    public function listQuestions($arrRow)
    {
        $key = $arrRow['published'] ? 'published' : 'unpublished';
        $date = Date::parse(Config::get('datimFormat'), $arrRow['tstamp']);
        return '
<div class="cte_type ' . $key . '"><strong>' . $arrRow['question'] . '</strong> - ' . $date . '</div>
<div class="limit_height' . (!Config::get('doNotCollapse') ? ' h52' : '') . '">
' . StringUtil::insertTagToSrc($arrRow['answer']) . '
</div>' . "\n";
    }
开发者ID:contao,项目名称:faq-bundle,代码行数:17,代码来源:tl_faq.php


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