Question

I'm at my first day with Yii

I've just learned how to filter columns

$dataProvider=new CActiveDataProvider('User', 
            array(
                'criteria' => array(
                                'select' => 'id, username, realname, email, companyId, languageId, registrationDate',
                                'order' => 'username ASC',
                                )
                 )
    );
    $this->render('index',array(
        'dataProvider'=>$dataProvider,
    ));

Now I've a problem: the 'registrationdDate' is a MySql datestamp.

So i need to show localized... how can I do this ?

the code of the view is a list. I'm listing using this:

<td><?php echo CHtml::encode($data->registrationDate); ?></td>

What can be done to detect user locale? And how to format a "2012-10-13 13:33:45", for example, into the correct localized string?

For italian it will be 13/10/2012 or 13-10-2012 with appended 13:33:45

Was it helpful?

Solution

The simplest way would be:

<td>
        <?php echo Yii::app()->locale->dateFormatter
                  ->formatDateTime($data->registrationDate); ?>
</td>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top