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


PHP QDateTime::PHPDate方法代码示例

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


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

示例1: GetControlHtml

 protected function GetControlHtml()
 {
     // Ignore Class
     $strCssClass = $this->strCssClass;
     $this->strCssClass = '';
     $strAttributes = $this->GetAttributes();
     $this->strCssClass = $strCssClass;
     $strStyle = $this->GetStyleAttributes();
     if ($strStyle) {
         $strAttributes .= sprintf(' style="%s"', $strStyle);
     }
     $strCommand = sprintf(' onchange="Qcodo__DateTimePicker_Change(\'%s\', this);"', $this->strControlId);
     if ($this->dttDateTime) {
         $dttDateTime = $this->dttDateTime;
     } else {
         $dttDateTime = new QDateTime();
     }
     $strToReturn = '';
     // Generate Date-portion
     switch ($this->strDateTimePickerType) {
         case QDateTimePickerType::Date:
         case QDateTimePickerType::DateTime:
         case QDateTimePickerType::DateTimeSeconds:
             // Month
             $strMonthListbox = sprintf('<select name="%s_lstMonth" id="%s_lstMonth" class="month" %s%s>', $this->strControlId, $this->strControlId, $strAttributes, $strCommand);
             if (!$this->blnRequired || $dttDateTime->IsDateNull()) {
                 $strMonthListbox .= '<option value="">--</option>';
             }
             $dttMonth = new QDateTime('2000-01-01');
             for ($intMonth = 1; $intMonth <= 12; $intMonth++) {
                 if (!$dttDateTime->IsDateNull() && $dttDateTime->Month == $intMonth || $this->intSelectedMonth == $intMonth) {
                     $strSelected = ' selected="selected"';
                 } else {
                     $strSelected = '';
                 }
                 $dttMonth->Month = $intMonth;
                 $strMonthListbox .= sprintf('<option value="%s"%s>%s</option>', $intMonth, $strSelected, $dttMonth->ToString('MMM'));
             }
             $strMonthListbox .= '</select>';
             // Day
             $strDayListbox = sprintf('<select name="%s_lstDay" id="%s_lstDay" class="day" %s%s>', $this->strControlId, $this->strControlId, $strAttributes, $strCommand);
             if (!$this->blnRequired || $dttDateTime->IsDateNull()) {
                 $strDayListbox .= '<option value="">--</option>';
             }
             if ($dttDateTime->IsDateNull()) {
                 if ($this->blnRequired) {
                     // New DateTime, but we are required -- therefore, let's assume January is preselected
                     for ($intDay = 1; $intDay <= 31; $intDay++) {
                         $strDayListbox .= sprintf('<option value="%s">%s</option>', $intDay, $intDay);
                     }
                 } else {
                     // New DateTime -- but we are NOT required
                     // See if a month has been selected yet.
                     if ($this->intSelectedMonth) {
                         $intSelectedYear = $this->intSelectedYear ? $this->intSelectedYear : 2000;
                         $intDaysInMonth = date('t', mktime(0, 0, 0, $this->intSelectedMonth, 1, $intSelectedYear));
                         for ($intDay = 1; $intDay <= $intDaysInMonth; $intDay++) {
                             if ($dttDateTime->Day == $intDay || $this->intSelectedDay == $intDay) {
                                 $strSelected = ' selected="selected"';
                             } else {
                                 $strSelected = '';
                             }
                             $strDayListbox .= sprintf('<option value="%s"%s>%s</option>', $intDay, $strSelected, $intDay);
                         }
                     } else {
                         // It's ok just to have the "--" marks and nothing else
                     }
                 }
             } else {
                 $intDaysInMonth = $dttDateTime->PHPDate('t');
                 for ($intDay = 1; $intDay <= $intDaysInMonth; $intDay++) {
                     if ($dttDateTime->Day == $intDay || $this->intSelectedDay == $intDay) {
                         $strSelected = ' selected="selected"';
                     } else {
                         $strSelected = '';
                     }
                     $strDayListbox .= sprintf('<option value="%s"%s>%s</option>', $intDay, $strSelected, $intDay);
                 }
             }
             $strDayListbox .= '</select>';
             // Year
             $strYearListbox = sprintf('<select name="%s_lstYear" id="%s_lstYear" class="year" %s%s>', $this->strControlId, $this->strControlId, $strAttributes, $strCommand);
             if (!$this->blnRequired || $dttDateTime->IsDateNull()) {
                 $strYearListbox .= '<option value="">--</option>';
             }
             for ($intYear = $this->intMinimumYear; $intYear <= $this->intMaximumYear; $intYear++) {
                 if ($dttDateTime->Year == $intYear || $this->intSelectedYear == $intYear) {
                     $strSelected = ' selected="selected"';
                 } else {
                     $strSelected = '';
                 }
                 $strYearListbox .= sprintf('<option value="%s"%s>%s</option>', $intYear, $strSelected, $intYear);
             }
             $strYearListbox .= '</select>';
             // Put it all together
             switch ($this->strDateTimePickerFormat) {
                 case QDateTimePickerFormat::MonthDayYear:
                     $strToReturn .= $strMonthListbox . $strDayListbox . $strYearListbox;
                     break;
                 case QDateTimePickerFormat::DayMonthYear:
//.........这里部分代码省略.........
开发者ID:snowmann,项目名称:qcodo,代码行数:101,代码来源:QDateTimePicker.class.php


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