I am working on a Laravel application that has the timezone set to UTC in the config/app.php
and config/database.php
files, and the timezone on the MySQL server is set to America/Denver and cannot be changed there because we have multiple apps using that server.
The problem is, when saving a new model with timestamps, the created_at
/updated_at
are set in the America/Denver timezone, when I need them to use the UTC timezone. I have played around quite a bit and have tried the following with no luck:
Made sure that the timezone settings were not incorrectly cached as suggested here and here:
$ php artisan cache:clear
$ php artisan view:clear
$ php artisan config:cache
Set my PHP script timezone to UTC as suggested here and here and outlined here:
date_default_timezone_set('UTC')
Set the MySQL session timezone to UTC as suggested here and outlined here:
DB::statement("SET time_zone='UTC';")
DB::select('SELECT @@global.time_zone, @@session.time_zone;')
I'm out of ideas. Any suggestions would be great!