Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Nemiq's avatar
Level 1

Laravel time zone setting and mysql

Hi,

My web hotel is running with timezone CEST (+02:00). I've have Laravel timezone set to UTC which gives me correct UTC times when printing it. I.e. server time is 15:00 but it prints 13:00.

When I store these values to my mysql database it stores correctly in UTC time (which is what I want).

Problem is that during DST (day light time saving) which happened last night, the time is considered invalid between 02:00-03:00 (because mysql compares it to CEST), resulting in failed post inserts.

Reading up on SO (https://stackoverflow.com/questions/25855837/mysql-5-6-19-timestamp-cant-accept-many-correct-values) I then set 'timezone' => '+00:00' in my Laravel database configuration.

Now inserts between 02:00-03:00 works but database is storing all timestamps with +2 hours.

The database I have is decently big (imported from old system) and all old posts have their timestamps in UTC.

What am I doing wrong? And how are you guys handling it?

0 likes
1 reply
Nemiq's avatar
Level 1

Been reading through a lot of topics on internet and it seems this is quite a challenging topic when it comes to global sites with different time zones for its users. Laravel is by default using timestamp for created_at/updated_at columns in Mysql.

If I change those to datetime and set App timezone to UTC + Database timezone to +00:00 then I get the desired result.

Question is.. what other problems may I run into by doing this change?

Please or to participate in this conversation.