nasht00
(Yiiframework Com)
1
Values of type "timestamp" in MySQL are stored as "string" in the Yii active record models.
What’s the preferred way of storing and retrieving timestamps?
Sometimes I have timestamp data as UNIX time, sometimes as datetime representations…
If I do $widget->timestamp = time(); it doesn’t work correctly.
dadudeness
(Dadudeness)
2
Try using the beforeSave() and afterFind() functions of the model:
beforeSave():
$this->YOUR-DATE-FIELD = date('Y-m-d', strtotime($this->YOUR-DATE-FIELD));
afterFind():
$this->YOUR-DATE-FIELD=date('d.m.Y', strtotime($this->YOUR-DATE-FIELD));
You can display the native MySQL-timestamp in whatever format you like. After changing it will be converted to the MySQL-Format again.