Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format date in the indexSuccess.php

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 showSuccess.php Could you help me? thanks

like image 494
Eva Dias Avatar asked Jul 14 '26 19:07

Eva Dias


2 Answers

You can make in symfony in your indexSuccess.php and showSuccess.php instead of for example:

 <?php $value->getCreatedAt() ?>

next:

 <?php echo date('d.M.Y', strtotime($value->getCreatedAt())) ?>

You can use other formats.

like image 134
denys281 Avatar answered Jul 17 '26 18:07

denys281


The format of some data absolutely not belongs into controller context - so please use

use_helper("date");
echo format_date($myDate);

from symfony's date helper in your template (showSuccess.php, blaSuccess.php) or partial (form.php, list.php, test.php) !

You'll find more informations here http://www.symfony-project.org/gentle-introduction/1_4/en/13-I18n-and-L10n#chapter_13_sub_outputting_data_in_the_user_s_culture or in the source file.

like image 30
domi27 Avatar answered Jul 17 '26 18:07

domi27



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!