How can I change the timezone of the outputted date in Laravel 4?

人走茶凉 提交于 2019-11-29 17:30:17

You need to use the Carbon function copy() to keep the timezone unchanged on your object. Then you can just set the timezone to whatever you want and 'output' the result.

$entity->created_at->copy()->tz(Auth::user()->timezone)->format('M j, Y \\a\\t g:i A');

As for timezones - it is just PHP timezones.

$tzlist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!