修复错误的日期时间差计算

This commit is contained in:
Chenx221 2024-04-04 15:37:48 +08:00
parent fefd880e43
commit 42344ec3f1
Signed by: chenx221
GPG Key ID: D7A9EC07024C3021
2 changed files with 3 additions and 3 deletions

View File

@ -41,7 +41,7 @@ $this->title = '登录日志';
'format' => 'html',
'enableSorting' => false,
'value' => function ($model) {
return nl2br($model->login_time . "\n(" . Yii::$app->formatter->asRelativeTime($model->login_time) . ")");
return nl2br($model->login_time . "\n(" . Yii::$app->formatter->asRelativeTime(new DateTime($model->login_time, new DateTimeZone('GMT+8'))) . ")");
},
],
[

View File

@ -83,11 +83,11 @@ $this->registerCssFile('@web/css/admin-userv.css');
}],
['attribute' => 'created_at', 'label' => '创建时间', 'value' => function ($model) {
// 日期时间 (xx天前)
return $model->created_at . ' (' . Yii::$app->formatter->asRelativeTime($model->created_at) . ')';
return $model->created_at . ' (' . Yii::$app->formatter->asRelativeTime(new DateTime($model->created_at, new DateTimeZone('GMT+8'))) . ')';
}],
['attribute' => 'last_login', 'label' => '最后登录时间', 'value' => function ($model) {
// 日期时间 (xx天前)
return $model->last_login . ' (' . Yii::$app->formatter->asRelativeTime($model->last_login) . ')';
return $model->last_login . ' (' . Yii::$app->formatter->asRelativeTime(new DateTime($model->last_login, new DateTimeZone('GMT+8'))) . ')';
}],
['attribute' => 'last_login_ip', 'label' => '上次登录IP', 'value' => function ($model) use ($IPLocation) {
if (Yii::$app->params['enableIpInfo']) {