44 parent::__construct($factoryElement, $factoryCollection, $escaper,
$data);
46 $this->setExtType(
'textfield');
47 if (isset(
$data[
'value'])) {
81 if (
$value instanceof \DateTimeInterface) {
85 if (preg_match(
'/^[0-9]+$/',
$value)) {
91 $this->_value = new \DateTime(
$value,
new \DateTimeZone($this->localeDate->getConfigTimezone()));
92 }
catch (\Exception $e) {
107 if (empty($this->_value)) {
111 $format = $this->getDateFormat();
113 $format .= $this->getTimeFormat() ? $this->getTimeFormat() :
'';
115 return $this->localeDate->formatDateTime(
120 $this->_value->getTimezone(),
132 if (empty($this->_value)) {
149 $this->
addClass(
'admin__control-text input-text');
150 $dateFormat = $this->getDateFormat() ?: $this->getFormat();
151 $timeFormat = $this->getTimeFormat();
152 if (empty($dateFormat)) {
153 throw new \Exception(
154 'Output format is not specified. ' .
155 'Please specify "format" key in constructor, or set it using setFormat().' 159 $dataInit =
'data-mage-init="' . $this->
_escape(
163 'dateFormat' => $dateFormat,
164 'showsTime' => !empty($timeFormat),
165 'timeFormat' => $timeFormat,
166 'buttonImage' => $this->getImage(),
167 'buttonText' =>
'Select Date',
168 'disabled' => $this->getDisabled(),
169 'minDate' => $this->getMinDate(),
170 'maxDate' => $this->getMaxDate(),
177 '<input name="%s" id="%s" value="%s" %s %s />',