Prado\Util\TSimpleDateFormatter::format PHP Метод

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

Format the date according to the pattern.
public format ( $value ) : string
Результат string formatted date.
    public function format($value)
    {
        $date = $this->getDate($value);
        $bits['yyyy'] = $date['year'];
        $bits['yy'] = substr("{$date['year']}", -2);
        $bits['MM'] = str_pad("{$date['mon']}", 2, '0', STR_PAD_LEFT);
        $bits['M'] = $date['mon'];
        $bits['dd'] = str_pad("{$date['mday']}", 2, '0', STR_PAD_LEFT);
        $bits['d'] = $date['mday'];
        $pattern = preg_replace('/M{3,4}/', 'MM', $this->pattern);
        return str_replace(array_keys($bits), $bits, $pattern);
    }

Usage Example

Пример #1
0
 /**
  * Sets the date for the date picker using timestamp.
  * @param float time stamp for the date picker
  */
 public function setTimeStamp($value)
 {
     if ($value === null || is_string($value) && trim($value) === '') {
         $this->setText('');
     } else {
         $date = TPropertyValue::ensureFloat($value);
         $formatter = new TSimpleDateFormatter($this->getDateFormat());
         $this->setText($formatter->format($date));
     }
 }
All Usage Examples Of Prado\Util\TSimpleDateFormatter::format