Date as column type?
I am writing a module with custom model, whose entities have dates as property.
It looks like x-cart handles dates as integers via timestamp, but I will be importing the entities from a CSV file, in which they are entered as dates. So my question is, can we do something like Code:
/** |
Re: Date as column type?
Sure you can. But then you will have to covert it to timestamp every time you need to use it (or within its get method) unless you create your own controls to work with this field.
It is probably best to just either modify the csv file and covert the dates to timestamp or do this on the fly with the import. |
Re: Date as column type?
It turns out the things are a bit more complicated. The FormField class
View/FormField/Input/Text/Date.php, as its path suggests, treats dates as strings. So, I can't do Code:
* @Column (type="integer") and use View/FormField/Input/Text/Date.php for editing the entity, i.e. Code:
protected $schemaDefault = array( The only place, it seems to me, where there is the date to be input manually in X-Cart's original code, is the arrival date for products, but there, the class View/FormModel/Type/DatepickerType.php is used. My entities don't use the DTO, so I can't use this class. So, the question now is: how do I get around this problem? I would need something like Code:
public setMydate($value) { |
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. Code:
/** Code:
public function getBirthdate() for the formats 09-18-2019, 18.09.2019, 18-09-2019. Any idea on how to solve this? |
Re: Date as column type?
* @Column (type="integer")
*/ protected $mydate public getMydate { return $this->mydate } public setMydate($value) { $this->mydate=$value; return $this; } Regards PPCexpo |
Re: Date as column type?
Now it only works for 4 out of 8 formats. I don't know if this is because of x-cart update to 5.4.0.8 or upgrade of php/mariadb/apache or whatsoever server component, but the format 19-12-2019 (the one we were using!) works no longer.
Any idea where this comes from and how to solve it, other than switching the format? |
Re: Date as column type?
Quote:
Thank you very much, but
|
Re: Date as column type?
It now only works for four out of eight formats. It doesn't seem to be due to the latest version of X-Cart, nor has it been changed by any recent software updates. You may want to contact our support team for assistance.
* @Column (type="integer") */ protected $mydate public getMydate { return $this->mydate } public setMydate($value) { $this->mydate=$value; return $this; } Regards Ways101 |
All times are GMT -8. The time now is 07:00 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.