1

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

4

1 に答える 1

3

最も簡単な方法は次のとおりです。

<td>
        <?php echo Yii::app()->locale->dateFormatter
                  ->formatDateTime($data->registrationDate); ?>
</td>
于 2012-10-03T16:05:27.420 に答える