【发布时间】:2021-05-18 04:34:43
【问题描述】:
我尝试从数据库中选择create_data,数据库中的日期格式类似于“2021-05-18 11:06:01”,但是当我检索并显示它时,它会显示类似于“ 2021-05-18T03:06:01.000000Z”。有谁知道为什么会变成这样?我想要实际上类似于数据库存储的日期,即“2021-05-18 11:06:01”。但是DB里面的create_date格式是UTC+8,但是接收的时候会显示UTC格式。
数据返回
[0] => Array (
[id] => 1
[log_name] => login
[description] => login
[subject_type] => App\Models\Users
[subject_id] => 0
[causer_type] => App\Models\User
[causer_id] => 2
[properties] => ""
[created_at] => 2021-05-18T03:06:01.000000Z
);
代码
$lastLoggedActivity = ActivityLog::where('causer_id', $userid)
->orWhereIn('subject_id', $selectparentid)
->with('getLogType')
->with('getCauserDetails')
->orderBy('created_at', 'desc')
->get()
->toArray();
【问题讨论】:
-
created_at默认是碳实例,所以格式是这样的。你可以随意格式化它。 -
@zahidhasanemon,即使我将 app.php(时区)设置为我想要的,日期也会返回这样的格式