I want to format the created_at
field date from the original for something like 03.May.2011 to be shown in the indexSuccess.php
and in the sh
I believe the date is returned in a string format Y-m-d H:i:s
, as fits the MySQL datetime type. It would be nicest to convert this to a PHP DateTime
instance using DateTime::createFromFormat, presuming you are using PHP > 5.3.
So, in your controller:
$this->creation_date = DateTime::createFromFormat('Y-m-d H:i:s', $item->created_at);
Then, in your view:
format('d.F.Y') ?>
See also DateTime::format
If you are using PHP 5.2 or before, you can't use createFromFormat
. You probably want to fall back on strtotime:
$this->creation_date = strtotime($this->created_at);
and in the view: