【发布时间】:2020-07-17 02:08:51
【问题描述】:
我试图在 MySQL 中获取与我的数据相同的时区,但 JSON 响应以不同的时间回复。
我尝试使用 Carbon,但结果始终显示相同(与我的时区不同)。
另外,我的时区在app.php 到'timezone' => 'Asia/Kuala_Lumpur',将数据存储为我的国家时区。
$todayentry = SensorTissue::whereDate('entryDate', Carbon::now()->setTimezone(config('app.timezone')))->get()->sortBy('entryDate');
$todayentry = json_decode($todayentry);
return $todayentry;
json 响应的结果:
[{
"tsID": 10,
"entryDate": "2020-04-04T23:57:17.000000Z",
"sensorValue": 7
},
{
"tsID": 11,
"entryDate": "2020-04-04T23:57:34.000000Z",
"sensorValue": 6
}]
回复显示2020-04-04T23:57:34.000000Z
在我的数据库中应该是2020-04-05 07:57:34。
【问题讨论】:
标签: php json laravel eloquent php-carbon