How to customize date display?

Dear experts,

I want to display my date (unixtime in database) to display in a specified format (e.g: 12-10-2013) and saving back using unixtime again.

ProductPurchaseForm.php ```php class ProductPurchaseForm extends Form { $publishtime = new Text('publishtime', array('class'=>'form-control input-lg')); $this->add($publish_time); } ```

edit.html ```php <form id="product-purchase-update-form" class="form-horizontal" method="post" role="form"> {{ form.render("publish_time") }} </form> ```

ProductPurchaseController.php ```php public function saveAction() { if ($this->request->isPost()) { ProductPurchase::save(); } } ```

Where should I put the date filter for displaying with a specified format?

Thank you so much



How are you setting the value in the element? Is the value got from $_POST?


Yes. I got the value from $_POST

Any ideas?


Idea is very simple :) When you receive your POST publish_time, you can use strtotime in any variants: or when you binding POST data to model in controller, or when you save your data to table in model (beforeSave) just is easy :)