Changes
Title
unchanged
Save and Display Date/Time Fields in different formats in Yii2
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
date, format, time, datetime, save, display, i18n, extension, date control, datecontrol, timestamp, events, behavior
Content
changed
[...]
```php
'formatter' => [
'class' => 'yii\i18n\Formatter',
'dateFormat' => 'php:d-M-Y',
'datetimeFormat' => '
php:d-M-Y H:i:s',
'timeFormat' => '
php:H:i:s',
]
```[...]
```php
class Setup {
const DATE_FORMAT = 'php:Y-m-d';
const DATETIME_FORMAT = '
php:Y-m-d H:i:s';
const TIME_FORMAT = '
php:H:i:s';
public static function convert($dateStr, $type='date', $format = null) {
if ($type === 'datetime') {
$fmt = ($format == null) ? self::DATETIME_FORMAT : $format;
}[...]