Created_at save with wrong timezone

I have a laravel application and am trying to save user checks and checks in my database

I have a Checkins model and I write it as created_at and updated_at

on my local host it will save with the right time for my timezome (Egypt), I tried to change the app.php file to the next

  |-------------------------------------------------------------------------- | 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. | | This is a bad thing really i think there is a problem within the server, the datetime */ 'timezone' => 'EET', 

it works fine on my local host and saves with the current correct time, for saving it with the UTC time zone

Also, when I write the date command date in the production terminal, I get the following

 Tue Mar 31 12:46:38 EET 2015 

and I checked mysql for timezone and I found that it gets time from system time

 SELECT @@global.time_zone, @@session.time_zone; SYSTEM 

What is wrong here?

UPDATE:

I created a php page with date('H:i:s'); and printed the right time

+7
source share
5 answers

To set the time zone for your Laravel application, change 'timezone' to config/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. | | This is a bad thing really i think there is a problem within the server, the datetime */ 'timezone' => 'America/Los_Angeles', 

You can find the time zone you need here .

+7
source

By php documentation It is highly recommended that you use the correct time zone for your location, such as Asia/Shanghai or Australia/Perth Do not use EET or CET .

You can find the time zone for your location here.

0
source

Perhaps you are using insert or insertGetId to insert data?

If you insert Eloquent(like ->save()) data Eloquent(like ->save()) , the time will be correct.

0
source

You must change your time zone in config/app.php

Also, as said here, you must run the following commands to save your time zone changes:

php artisan cache:clear php artisan view:clear php artisan config:cache

0
source

It looks like you forgot to run php artisan config: cache.

-2
source

Source: https://habr.com/ru/post/1216523/


All Articles