更改时区但仍获得 UTC

oso*_*sos 5 laravel

我已将我的 laravel 应用程序的时区更改为Africa\Cairo,并在 app.php 文件中更改了它

|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
*/

'timezone'        => 'Africa/Cairo',
Run Code Online (Sandbox Code Playgroud)

但是当我使用检查生产时区时Carbon::now(),我得到的时区是 UTC

我如何在 Carbon 中设置时区

dev*_*ev7 1

只需使用Carbon::now('Africa/Cairo'). 这应该能让你得到正确的时间。

希望这可以帮助。