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


PHP Formatter::formatDateTime方法代码示例

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


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

示例1: renderModelInput

    public static function renderModelInput(CModel $model, $field, $htmlOptions = array())
    {
        if (!$field->asa('CommonFieldsBehavior')) {
            throw new Exception('$field must have CommonFieldsBehavior');
        }
        if ($field->required) {
            if (isset($htmlOptions['class'])) {
                $htmlOptions['class'] .= ' x2-required';
            } else {
                $htmlOptions = array_merge(array('class' => 'x2-required'), $htmlOptions);
            }
        }
        $fieldName = $field->fieldName;
        if (!isset($field)) {
            return null;
        }
        switch ($field->type) {
            case 'text':
                return CHtml::activeTextArea($model, $field->fieldName, array_merge(array('title' => $field->attributeLabel), array_merge(array('encode' => false), $htmlOptions)));
            case 'date':
                $oldDateVal = $model->{$fieldName};
                $model->{$fieldName} = Formatter::formatDate($model->{$fieldName}, 'medium');
                Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
                $pickerOptions = array('dateFormat' => Formatter::formatDatePicker(), 'changeMonth' => false, 'changeYear' => true);
                if (Yii::app()->getLanguage() === 'fr') {
                    $pickerOptions['monthNamesShort'] = Formatter::getPlainAbbrMonthNames();
                }
                $input = Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $fieldName, 'mode' => 'date', 'options' => $pickerOptions, 'htmlOptions' => array_merge(array('title' => $field->attributeLabel), $htmlOptions), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true);
                $model->{$fieldName} = $oldDateVal;
                return $input;
            case 'dateTime':
                $oldDateTimeVal = $model->{$fieldName};
                $pickerOptions = array('dateFormat' => Formatter::formatDatePicker('medium'), 'timeFormat' => Formatter::formatTimePicker(), 'ampm' => Formatter::formatAMPM(), 'changeMonth' => true, 'changeYear' => true);
                if (Yii::app()->getLanguage() === 'fr') {
                    $pickerOptions['monthNamesShort'] = Formatter::getPlainAbbrMonthNames();
                }
                $model->{$fieldName} = Formatter::formatDateTime($model->{$fieldName});
                Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
                $input = Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $fieldName, 'mode' => 'datetime', 'options' => $pickerOptions, 'htmlOptions' => array_merge(array('title' => $field->attributeLabel), $htmlOptions), 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()), true);
                $model->{$fieldName} = $oldDateTimeVal;
                return $input;
            case 'dropdown':
                // Note: if desired to translate dropdown options, change the seecond argument to
                // $model->module
                $om = $field->getDropdownOptions();
                $multi = (bool) $om['multi'];
                $dropdowns = $om['options'];
                $curVal = $multi ? CJSON::decode($model->{$field->fieldName}) : $model->{$field->fieldName};
                $ajaxArray = array();
                if ($field instanceof Fields) {
                    $dependencyCount = X2Model::model('Dropdowns')->countByAttributes(array('parent' => $field->linkType));
                    $fieldDependencyCount = X2Model::model('Fields')->countByAttributes(array('modelName' => $field->modelName, 'type' => 'dependentDropdown', 'linkType' => $field->linkType));
                    if ($dependencyCount > 0 && $fieldDependencyCount > 0) {
                        $ajaxArray = array('ajax' => array('type' => 'GET', 'url' => Yii::app()->controller->createUrl('/site/dynamicDropdown'), 'data' => 'js:{
                                "val":$(this).val(),
                                "dropdownId":"' . $field->linkType . '",
                                "field":true, "module":"' . $field->modelName . '"
                            }', 'success' => '
                                function(data){
                                    if(data){
                                        data=JSON.parse(data);
                                        if(data[0] && data[1]){
                                            $("#' . $field->modelName . '_"+data[0]).html(data[1]);
                                        }
                                    }
                                }'));
                    }
                }
                $htmlOptions = array_merge($htmlOptions, $ajaxArray, array('title' => $field->attributeLabel));
                if ($multi) {
                    $multiSelectOptions = array();
                    if (!is_array($curVal)) {
                        $curVal = array();
                    }
                    foreach ($curVal as $option) {
                        $multiSelectOptions[$option] = array('selected' => 'selected');
                    }
                    $htmlOptions = array_merge($htmlOptions, array('options' => $multiSelectOptions, 'multiple' => 'multiple'));
                } elseif ($field->includeEmpty) {
                    $htmlOptions = array_merge($htmlOptions, array('empty' => Yii::t('app', "Select an option")));
                }
                return CHtml::activeDropDownList($model, $field->fieldName, $dropdowns, $htmlOptions);
            case 'dependentDropdown':
                return CHtml::activeDropDownList($model, $field->fieldName, array('' => '-'), array_merge(array('title' => $field->attributeLabel), $htmlOptions));
            case 'link':
                $linkSource = null;
                $linkId = '';
                $name = '';
                if (class_exists($field->linkType)) {
                    // Create a model for autocompletion:
                    if (!empty($model->{$fieldName})) {
                        list($name, $linkId) = Fields::nameAndId($model->{$fieldName});
                        $linkModel = X2Model::getLinkedModelMock($field->linkType, $name, $linkId, true);
                    } else {
                        $linkModel = X2Model::model($field->linkType);
                    }
                    if ($linkModel instanceof X2Model && $linkModel->asa('X2LinkableBehavior') instanceof X2LinkableBehavior) {
                        $linkSource = Yii::app()->controller->createUrl($linkModel->autoCompleteSource);
                        $linkId = $linkModel->id;
                        $oldLinkFieldVal = $model->{$fieldName};
//.........这里部分代码省略.........
开发者ID:tymiles003,项目名称:X2CRM,代码行数:101,代码来源:X2Model.php

示例2: generateFeedEmail

    public static function generateFeedEmail($filters, $userId, $range, $limit, $eventId, $deleteKey)
    {
        $image = Yii::app()->getAbsoluteBaseUrl(true) . '/images/x2engine.png';
        $msg = "<div id='wrap' style='width:6.5in;height:9in;margin-top:auto;margin-left:auto;margin-bottom:auto;margin-right:auto;'><html><body><center>";
        $msg .= '<table border="0" cellpadding="0" cellspacing="0" height="100%" id="top-activity" style="background: white; font-family: \'Helvetica Neue\', \'Helvetica\', Helvetica, Arial, sans-serif; font-weight: normal; font-style: normal; font-size: 14px; line-height: 1; color: #222222; position: relative; -webkit-font-smoothing: antialiased;background-color:#FAFAFA;height:25% !important; margin:0; padding:0; width:100% !important;" width="100%">' . "<tbody><tr><td align=\"center\" style=\"padding-top:20px;\" valign=\"top\">" . '<table border="0" cellpadding="0" cellspacing="0" id="templateContainer" style="border: 1px solid #DDDDDD;background-color:#FFFFFF;" width="600"><tbody>';
        $msg .= '<tr>
                    <td align="center" valign="top"><!-- // Begin Template Header \\ -->
			<table border="0" cellpadding="0" cellspacing="0" id="templateHeader" width="600">
                            <tbody>
				<tr>
                                    <td class="headerContent" style="color:#202020;font-weight:bold;line-height:100%;padding:0;text-align:center;vertical-align:middle;font-family: inherit;font-weight: normal;font-size: 14px;margin-bottom: 17px"><img id="headerImage campaign-icon" src="' . $image . '" style="border:0; height:auto; line-height:100%; outline:none; text-decoration:none;max-width:600px;" /></td>
                                </tr>
                                <tr>
                                    <td style="color:#202020;font-weight:bold;padding:5px;text-align:center;vertical-align:middle;font-family: inherit;font-weight: normal;font-size: 14px;"><h2>' . Yii::t('profile', 'Activity Feed Report') . '</h2></td>
                                </tr>
                            </tbody>
			</table>
                    <hr width="60%"></td><!-- // End Template Header \\ -->
		</tr>';
        $msg .= '<tr><td align="center" valign="top"><!-- // Begin Template Body \\ -->' . '<table border="0" cellpadding="0" cellspacing="0" id="templateBody" width="600"><tbody><tr>' . '<td valign="top"><!-- // Begin Module: Standard Content \\ -->' . '<table border="0" cellpadding="20" cellspacing="0" width="100%"><tbody>';
        $params = array();
        $userRecord = X2Model::model('Profile')->findByPk($userId);
        $params[':username'] = $userRecord->username;
        $parsedFilters = Events::parseFilters($filters, $params);
        $visibilityCondition = $parsedFilters['conditions']['visibility'];
        $accessCriteria = Events::model()->getAccessCriteria();
        $userCondition = $parsedFilters['conditions']['users'];
        $typeCondition = $parsedFilters['conditions']['types'];
        $subtypeCondition = $parsedFilters['conditions']['subtypes'];
        $condition = "type!='comment' AND (type!='action_reminder' " . "OR user=:username) AND " . "(type!='notif' OR user=:username)" . $visibilityCondition . $userCondition . $typeCondition . $subtypeCondition . ' AND (' . $accessCriteria->condition . ')';
        switch ($range) {
            case 'daily':
                $timeRange = 24 * 60 * 60;
                break;
            case 'weekly':
                $timeRange = 7 * 24 * 60 * 60;
                break;
            case 'monthly':
                $timeRange = 30 * 24 * 60 * 60;
                break;
            default:
                $timeRange = 24 * 60 * 60;
                break;
        }
        $condition .= " AND timestamp BETWEEN " . (time() - $timeRange) . " AND " . time();
        $topTypes = Yii::app()->db->createCommand()->select('type, COUNT(type)')->from('x2_events')->where($condition, array_merge($params, $accessCriteria->params))->group('type')->order('COUNT(type) DESC')->limit(5)->queryAll();
        $topUsers = Yii::app()->db->createCommand()->select('user, COUNT(user)')->from('x2_events')->where($condition, array_merge($params, $accessCriteria->params))->group('user')->order('COUNT(user) DESC')->limit(5)->queryAll();
        $msg .= "<tr><td style='text-align:center;'>";
        $msg .= "<div>" . Yii::t('profile', "Here's your {range} update on what's been going on in X2Engine!", array('{range}' => Yii::t('profile', $range))) . "</div><br>" . "<div>Time Range: <em>" . Formatter::formatDateTime(time() - $timeRange) . "</em> to <em>" . Formatter::formatDateTime(time()) . "</em></div>";
        $msg .= "</tr></td>";
        $msg .= "<tr><td><table width='100%'><tbody>";
        $msg .= "<tr><th>" . Yii::t('profile', "Top Activity") . "</th><th>" . Yii::t('profile', "Top Users") . "</th></tr>";
        for ($i = 0; $i < 5; $i++) {
            $msg .= "<tr><td style='text-align:center;'>";
            if (isset($topTypes[$i])) {
                $type = Events::parseType($topTypes[$i]['type']);
                $count = $topTypes[$i]['COUNT(type)'];
                $msg .= $count . " " . $type;
            }
            $msg .= "</td><td style='text-align:center;'>";
            if (isset($topUsers[$i]) && $topUsers[$i]['COUNT(user)'] > 0) {
                $username = User::getUserLinks($topUsers[$i]['user'], false, true);
                $count = $topUsers[$i]['COUNT(user)'];
                $msg .= $count . " " . Yii::t('profile', "events from") . " " . $username . ".";
            }
            $msg .= "</td></tr>";
        }
        $msg .= "</tbody></table></td></tr>";
        $msg .= "<tr><td style='text-align:center'><hr width='60%'>";
        $msg .= "<tr><td style='text-align:center;'>" . Yii::t('profile', "Here's the {limit} most recent items on the Activity Feed.", array('{limit}' => $limit)) . "</td></tr>";
        $msg .= "</td></tr>";
        $msg .= "<tr><td style='text-align:center'><hr width='60%'><table><tbody>";
        $events = new CActiveDataProvider('Events', array('criteria' => array('condition' => $condition, 'order' => 'timestamp DESC', 'params' => array_merge($params, $accessCriteria->params)), 'pagination' => array('pageSize' => $limit)));
        foreach ($events->getData() as $event) {
            $msg .= "<tr>";
            $avatar = Yii::app()->db->createCommand()->select('avatar')->from('x2_profile')->where('username=:user', array(':user' => $event->user))->queryScalar();
            if (!empty($avatar) && file_exists($avatar)) {
                $avatar = Yii::app()->getAbsoluteBaseUrl() . '/' . $avatar;
            } else {
                $avatar = Yii::app()->getAbsoluteBaseUrl(true) . '/uploads/default.png';
            }
            $typeFile = $event->type;
            if (in_array($event->type, array('email_sent', 'email_opened'))) {
                if (in_array($event->subtype, array('quote', 'invoice'))) {
                    $typeFile .= "_{$event->subtype}";
                }
            }
            if ($event->type == 'record_create') {
                switch ($event->subtype) {
                    case 'call':
                        $typeFile = 'voip_call';
                        break;
                    case 'time':
                        $typeFile = 'log_time';
                        break;
                }
            }
            $imgFile = $avatar;
            if (file_exists(Yii::app()->theme->getBasePath() . '/images/eventIcons/' . $typeFile . '.png')) {
                $imgFile = Yii::app()->getAbsoluteBaseUrl() . '/themes/' . Yii::app()->theme->getName() . '/images/eventIcons/' . $typeFile . '.png';
//.........这里部分代码省略.........
开发者ID:shuvro35,项目名称:X2CRM,代码行数:101,代码来源:Events.php

示例3:

            <?php 
echo $data->getLink();
?>
        </div>
        <div class="topic-attributes">
            <div class="topic-reply-count">
                <?php 
echo $data->renderAttribute('replyCount');
?>
            </div>
            <div class="topic-last-updated">
                <div class='avatar-container'>
                <?php 
echo Profile::renderFullSizeAvatar($data->lastPost->getAuthorId(), 30);
?>
                </div>
                <div class="topic-last-updated-text">
                    <?php 
echo User::getUserLinks($data->lastPost->updatedBy);
?>
<br>
                    <?php 
echo Formatter::formatDateTime($data->lastPost->createDate);
?>
                </div>
            </div>
        </div>
    </div>
</div>

开发者ID:dsyman2,项目名称:X2CRM,代码行数:29,代码来源:_viewTopic.php

示例4: elseif

        if (in_array($model->type, array('event', 'time', 'call'))) {
            echo "<div class='complete-date-container'>";
            echo $form->label($model, 'completeDate');
            if (is_numeric($model->completeDate)) {
                $model->completeDate = Formatter::formatDateTime($model->completeDate);
            }
            echo $form->textField($model, 'completeDate');
            echo "</div>";
        }
        echo "</span>";
        echo "<div class='field-value'>";
        echo "<span style='color:grey'>" . $model->getAttributeLabel('dueDate', true) . ':' . " </span>" . '<b>' . $model->formatDueDate() . '</b>';
        echo "</div>";
        if (in_array($model->type, array('event', 'time', 'call'))) {
            echo "<div class='field-value'>";
            echo "<span style='color:grey'>" . $model->getAttributeLabel('completeDate', true) . ':' . " </span>" . '<b>' . Formatter::formatDateTime($model->completeDate) . '</b>';
            echo "</div>";
        }
    } elseif (!empty($model->createDate)) {
        echo Yii::t('actions', 'Created:') . " " . Formatter::formatLongDateTime($model->createDate) . '</b>';
    } else {
        echo "&nbsp;";
    }
} else {
    echo Yii::t('actions', 'Completed {date}', array('{date}' => Formatter::formatCompleteDate($model->completeDate)));
}
?>
                </span>
                <span>
                    <span id="controls">
                        <?php 
开发者ID:dsyman2,项目名称:X2CRM,代码行数:31,代码来源:_viewFrame.php

示例5: array

	<div class="cell dialog-cell" style="float: none;">
		<?php 
echo $model->actionDescription;
?>
	</div>
</div>

<div class="row">
	<div class="cell dialog-cell">
		<?php 
echo $form->label($model, $isEvent ? 'startDate' : 'dueDate', array('class' => 'dialog-label'));
echo Formatter::formatDateTime($model->dueDate);
//format date from DATETIME
if ($isEvent) {
    echo $form->label($model, 'endDate', array('class' => 'dialog-label'));
    echo Formatter::formatDateTime($model->completeDate);
    //format date from DATETIME
}
echo $form->label($model, 'allDay', array('class' => 'dialog-label'));
echo $form->checkBox($model, 'allDay', array('onChange' => 'giveSaveButtonFocus();', 'disabled' => 'disabled'));
?>
	</div>

	<div class="cell dialog-cell">
		<?php 
echo $form->label($model, 'priority', array('class' => 'dialog-label'));
$priorityArray = Actions::getPriorityLabels();
echo isset($priorityArray[$model->priority]) ? $priorityArray[$model->priority] : "";
?>
	</div>
	<div class="cell dialog-cell">
开发者ID:tymiles003,项目名称:X2CRM,代码行数:31,代码来源:viewAction.php

示例6: array

    ?>
            <div class="cell">
                <?php 
    echo $form->labelEx($actionModel, 'startDate');
    $actionModel->dueDate = Formatter::formatDateTime($actionModel->dueDate);
    echo X2Html::activeDatePicker($actionModel, 'dueDate', $form->resolveHtmlOptions($actionModel, 'dueDate', array('onClick' => "\$('#ui-datepicker-div').css('z-index', '20');")), 'datetime', array('dateFormat' => Formatter::formatDatePicker('medium'), 'timeFormat' => Formatter::formatTimePicker(), 'ampm' => Formatter::formatAMPM(), 'changeMonth' => false));
    ?>
            </div>
            <?php 
}
if ($actionModel->complete == 'Yes' || $actionModel->isTimedType) {
    ?>
                <div class="cell">
                    <?php 
    echo $form->labelEx($actionModel, $actionModel->isTimedType ? 'endDate' : 'completeDate');
    $actionModel->completeDate = Formatter::formatDateTime($actionModel->completeDate);
    echo X2Html::activeDatePicker($actionModel, 'completeDate', $form->resolveHtmlOptions($actionModel, 'completeDate', array('onClick' => "\$('#ui-datepicker-div').css('z-index', '20');")), 'datetime', array('dateFormat' => Formatter::formatDatePicker('medium'), 'timeFormat' => Formatter::formatTimePicker(), 'ampm' => Formatter::formatAMPM(), 'changeMonth' => false));
    ?>
                </div>
            <?php 
}
?>
        </div><!-- #action-backdating -->
</div><!-- .form -->
<?php 
if (!$backdating && file_exists(__DIR__ . DIRECTORY_SEPARATOR . '_actionTimersForm.php') && $actionModel->complete == 'Yes') {
    $this->renderPartial('_actionTimersForm', array('model' => $actionModel, 'form' => $form));
}
?>
</div>
<?php 
开发者ID:keyeMyria,项目名称:CRM,代码行数:31,代码来源:_form.php

示例7: activeDatePicker

 /**
  * @param CModel $model 
  * @param string $attribute 
  * @param array (optional) $htmlOptions 
  * @return string
  */
 public static function activeDatePicker(CModel $model, $attribute, array $htmlOptions = array(), $mode = 'date', array $options = array())
 {
     $options = array_merge(array('dateFormat' => Formatter::formatDatePicker(), 'changeMonth' => true, 'changeYear' => true), $options);
     ob_start();
     ob_implicit_flush(false);
     Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
     $model->{$attribute} = Formatter::formatDateTime($model->{$attribute});
     $renderWidget = function () use($model, $attribute, $htmlOptions, $mode, $options) {
         Yii::app()->controller->widget('CJuiDateTimePicker', array('model' => $model, 'attribute' => $attribute, 'mode' => $mode, 'options' => $options, 'htmlOptions' => $htmlOptions, 'language' => Yii::app()->language == 'en' ? '' : Yii::app()->getLanguage()));
     };
     if (Yii::app()->controller->isAjaxRequest()) {
         // process output if this is an ajax request
         X2Widget::ajaxRender($renderWidget);
     } else {
         $renderWidget();
     }
     return ob_get_clean();
 }
开发者ID:shuvro35,项目名称:X2CRM,代码行数:24,代码来源:X2Html.php

示例8: getLastUpdateInfo

 public function getLastUpdateInfo()
 {
     if (!empty($this->updatedBy) && !empty($this->lastUpdated)) {
         return Formatter::formatDateTime($this->lastUpdated);
     }
     return '&nbsp;';
 }
开发者ID:dsyman2,项目名称:X2CRM,代码行数:7,代码来源:FileSystemObject.php

示例9: array

        </div>
        <div class='topic-text'>
            <div class='topic-timestamp-text'>
                <?php 
echo Yii::t('topics', 'Posted {datetime}.', array('{datetime}' => Formatter::formatDateTime($data->createDate, 'medium')));
?>
            </div>
            <br>
            <?php 
echo Formatter::convertLineBreaks(x2base::convertUrls($data->text));
?>
            <div class='topic-timestamp-text'>
                <br>
                <?php 
if ($data->isEdited()) {
    echo Yii::t('topics', 'Edited by {user} - {datetime}.', array('{user}' => User::getUserLinks($data->updatedBy, false, true), '{datetime}' => Formatter::formatDateTime($data->lastUpdated, 'medium')));
}
?>
            </div>
        </div>

    </div>
    <div class='topic-footer'>
            <?php 
if (count($data->attachments) > 0) {
    echo "<div class='topic-attachment-label'>";
    echo Yii::t('topics', 'Attachments');
    echo "</div>";
    echo "<div class='topic-attachment-list'>";
    foreach ($data->attachments as $media) {
        echo '<span class="x2-pillbox topic-attachment">' . $media->getMediaLink() . '</span>';
开发者ID:tymiles003,项目名称:X2CRM,代码行数:31,代码来源:_viewTopicReply.php

示例10: array

}
?>
                <li>
                    <a class='edit-reply-button' href='<?php 
echo $this->createAbsoluteUrl('/topics/mobileUpdateReply', array('id' => $data->id));
?>
'><?php 
echo CHtml::encode(Yii::t('mobile', 'Edit'));
?>
</a>
                </li>
            </ul>
        </div>
        <div class='create-date'>
        <?php 
echo Formatter::formatDateTime($data->createDate, 'medium');
?>
        </div>

        <!--<div class='clearfix'></div>-->
    </div>
    <div class='reply-text'>
        <?php 
echo Formatter::convertLineBreaks(x2base::convertUrls($data->text));
?>
    </div>

    <div class='reply-attachments'>
    <?php 
/*$found = false;
  foreach ($data->attachments as $attachment) {
开发者ID:tymiles003,项目名称:X2CRM,代码行数:31,代码来源:_topicsViewItem.php


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