timezone = $timezone; $this->booleanUtils = $booleanUtils; parent::__construct($context, $uiComponentFactory, $components, $data); } /** * @inheritdoc * @since 101.1.1 */ public function prepare() { $config = $this->getData('config'); $config['filter'] = [ 'filterType' => 'dateRange', 'templates' => [ 'date' => [ 'options' => [ 'dateFormat' => $this->timezone->getDateFormatWithLongYear() ] ] ] ]; $this->setData('config', $config); parent::prepare(); } /** * @inheritdoc */ public function prepareDataSource(array $dataSource) { if (isset($dataSource['data']['items'])) { foreach ($dataSource['data']['items'] as & $item) { if (isset($item[$this->getData('name')]) && $item[$this->getData('name')] !== "0000-00-00 00:00:00" ) { $date = $this->timezone->date(new \DateTime($item[$this->getData('name')])); $timezone = isset($this->getConfiguration()['timezone']) ? $this->booleanUtils->convert($this->getConfiguration()['timezone']) : true; if (!$timezone) { $date = new \DateTime($item[$this->getData('name')]); } $item[$this->getData('name')] = $date->format('Y-m-d H:i:s'); } } } return $dataSource; } }