我有长期价值在
$updatedTime = 1486270800000;此值要转换为格式为2015-05-25 00:10:10的日期
现在,我正在尝试这段代码
echo Yii::$app->formatter->format($updatedTime, 'date');截止日期为2014年5月22日。我想要2015-05-25 00:10:10格式
发布于 2015-05-26 15:13:42
已更新
试一试
echo Yii::$app->formatter->asDatetime($updatedTime/1000, 'php:Y-m-d H:i:s'); 高于ISO值将给出2017-02-05 10:30:00 ISO值。
http://www.yiiframework.com/doc-2.0/yii-i18n-formatter.html#asDatetime%28%29-detail
发布于 2015-05-27 15:15:34
在配置文件中,将以下代码添加到components
// other configs
'components' => [
// other components here
'formatter' => [
'datetimeFormat' => 'php:Y-m-d h:i:s',
],
],设置日期格式时:echo Yii::$app->formatter->format($updatedTime, 'datetime');
https://stackoverflow.com/questions/30451623
复制相似问题