Prado\I18N\core\DateTimeFormatInfo::formatDateTime PHP Метод

formatDateTime() публичный Метод

The default is "Date Time".
public formatDateTime ( $date, $time ) : string
Результат string date and time formated
    function formatDateTime($date, $time)
    {
        $pattern = $this->getDateTimeOrderPattern();
        return str_replace(array('{0}', '{1}'), array($time, $date), $pattern);
    }

Usage Example

Пример #1
0
 /**
  * Get the pattern from DateTimeFormatInfo or some predefined patterns.
  * If the $pattern parameter is an array of 2 element, it will assume
  * that the first element is the date, and second the time
  * and try to find an appropriate pattern and apply
  * DateTimeFormatInfo::formatDateTime
  * See the tutorial documentation for futher details on the patterns.
  * @param mixed a pattern.
  * @return string a pattern.
  * @see DateTimeFormatInfo::formatDateTime()
  */
 protected function getPattern($pattern)
 {
     if (is_array($pattern) && count($pattern) == 2) {
         return $this->formatInfo->formatDateTime($this->getPattern($pattern[0]), $this->getPattern($pattern[1]));
     }
     switch ($pattern) {
         case 'd':
             return $this->formatInfo->ShortDatePattern;
             break;
         case 'D':
             return $this->formatInfo->LongDatePattern;
             break;
         case 'p':
             return $this->formatInfo->MediumDatePattern;
             break;
         case 'P':
             return $this->formatInfo->FullDatePattern;
             break;
         case 't':
             return $this->formatInfo->ShortTimePattern;
             break;
         case 'T':
             return $this->formatInfo->LongTimePattern;
             break;
         case 'q':
             return $this->formatInfo->MediumTimePattern;
             break;
         case 'Q':
             return $this->formatInfo->FullTimePattern;
             break;
         case 'f':
             return $this->formatInfo->formatDateTime($this->formatInfo->LongDatePattern, $this->formatInfo->ShortTimePattern);
             break;
         case 'F':
             return $this->formatInfo->formatDateTime($this->formatInfo->LongDatePattern, $this->formatInfo->LongTimePattern);
             break;
         case 'g':
             return $this->formatInfo->formatDateTime($this->formatInfo->ShortDatePattern, $this->formatInfo->ShortTimePattern);
             break;
         case 'G':
             return $this->formatInfo->formatDateTime($this->formatInfo->ShortDatePattern, $this->formatInfo->LongTimePattern);
             break;
         case 'M':
         case 'm':
             return 'MMMM dd';
             break;
         case 'R':
         case 'r':
             return 'EEE, dd MMM yyyy HH:mm:ss';
             break;
         case 's':
             return 'yyyy-MM-ddTHH:mm:ss';
             break;
         case 'u':
             return 'yyyy-MM-dd HH:mm:ss z';
             break;
         case 'U':
             return 'EEEE dd MMMM yyyy HH:mm:ss';
             break;
         case 'Y':
         case 'y':
             return 'yyyy MMMM';
             break;
         default:
             return $pattern;
     }
 }