Reputation: 3
I want to format the created_at
field date from the original to something like 15h33 12/01/2012
to be shown in the indexSuccess.php.
Could you help me?
Upvotes: 0
Views: 7957
Reputation: 669
If you are using Propel rather then Doctrine then you can do this kind of thing:
$model->getCreatedAt('Y-m-d H:i:s');
Which is fabulously simple! Sadly Doctrine 1.2 doesn't implement this. I haven't used Doctrine2 so not sure whether you can do it with that.
Upvotes: 0
Reputation: 162
You can also use the Date helper like this in your view :
<?php use_helper('Date'); ?>
<?php echo format_date($comment->getCreatedAt(), 'dd-MM-yyyy, HH:mm'); ?>
Upvotes: 3
Reputation: 19999
In your actions script you want to do something like:
$createdAt = strtotime($dbResults['created_at']);
$this->createdAt = date('H\hi m/d/Y', $createdAt);
Then just reference the available createdAt in your template:
<div>Created at: <?php echo $createdAt?></div>
More date formatting options can be found at the PHP date Api docs.
Upvotes: 1