1. 返回值里设置格式
[
‘attribute‘ => ‘updatetime‘,
‘label‘=>‘更新时间‘,
‘value‘=>
function($model){
return date(‘Y-m-d H:i:s‘,$model->updatetime);
},
‘headerOptions‘ => [‘width‘ => ‘170‘],
],
2. 设置format
[
‘attribute‘=>‘created_at‘,
‘format‘=>[‘date‘, ‘php:Y-m-d‘],
],
3. 在component配置里设置全局formatter
‘components‘ => [
‘formatter‘ => [
‘dateFormat‘ => ‘dd.MM.yyyy‘,
‘decimalSeparator‘ => ‘,‘,
‘thousandSeparator‘ => ‘ ‘,
‘currencyCode‘ => ‘CNY‘, //货币单位
],
],
Yii2.0在GridView中日期格式设置的几种方法
原文:https://www.cnblogs.com/phplzx/p/12320320.html