![](/img/trans.png)
[英]How can I output saved timezone shorthand (GMT, UTC, EST etc) in Laravel
[英]Show the data into EST timezone from UTC timezone in laravel
我的created_at和Updated_at列已插入UTC时区。 现在,我想根据“ 美国/芝加哥 ”时区显示数据。 我正在使用Carbon库来获取结果。
下面是我编写的从数据库中获取信息的代码。
public function getAllUsers(){
$users = BaseUserModel::
select('id', 'email', 'created_at')
->whereDate(
'created_at',
'=',
Carbon::today('america/chicago')
)
->orderBy('created_at', 'desc')
->limit(5)->get();
return $users;
}
带有UTC时间的附加数据库条目。 现在,当我尝试执行查询时,仅获得一个输出( 2018-10-03 15:27:18 )。 但是我的预期输出应该同时出现在“美国/时区”中。
查看UTC与美国/芝加哥时区的时差。 https://www.worldtimebuddy.com/
您需要使用UTC日期/时间进行查询。 例如,如果您希望将CST从2018-10-03 0:00:00到2018-10-03 23:59:59 CST,则需要使用2018-10-03 6:00:00到2018-10-进行查询04 5:59:59取决于时区和夏令时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.