View Single Post
Old 09-18-2019, 08:48 AM
Ed B. Ed B. is offline

Join Date: Apr 2016
Posts: 332

Default Re: Date as column type?

I have found out a bit more. If I want to use XLite\View\FormField\Input\Text\Date and I use the date as the data type, then

the following code for setter works.

/** * Birth Date * @var string * * @Column (type="date") */ protected $birthdate = ''; public function setBirthdate($value) { $formats = \XLite\Core\Converter::getDateFormatsByStrftimeFormat(); $format = $formats[phpFormat]; $value = date_create_from_format($format, $value); $this->birthdate=$value; return $this; }
However, for the getter, I have a problem. If I write
public function getBirthdate() { $formats = \XLite\Core\Converter::getDateFormatsByStrftimeFormat(); $format = $formats[phpFormat]; return $this->birthdate->format($format); }
then it works for the 5 formats out of 8 possible, that is it doesn't work
for the formats 09-18-2019, 18.09.2019, 18-09-2019.

Any idea on how to solve this?
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote