I have dates in my database in this format yyyy-dd-mm (datatype date). How can I display these dates for example as 4 May, 2011? Using the following didn’t work as it interprets the date as a time and I don’t want to use a time:
echo Yii::app()->getDateFormatter()->formatDateTime((integer)$auction->end, 'long', 'short') . " EST";
Thanks for your help…
<?php echo Yii::app()->dateFormatter->formatDateTime(
you are dealing with php based framwork …so don’t forget to use basic functions of php.
you can also use date("j F, Y",strtotime($yourdatevariable));
Passing ‘null’ for time is the way to go.
Thanks guys, all solutions presented here work and I chose Mike’s manual approach because it allows me to format the date exactly how I wanted as described here: http://www.php.net/manual/en/function.date.php .
Note that CDateFormatter has the advantage that it automatically uses the right format for each country/locale (i18n). If you don’t need that, then date() is more apropriate and maybe simpler to use.