I am developing a Laravel 5.8 app that is connecting to 2 databases. One is the app's own database and the other is a legacy MySQL database. Sadly the legacy database stores datetimes as 'Europe/London' not UTC.
Is there a nice way to auto adapt the 'Europe/London' dates to 'UTC' in my Laravel models?
I have seen that you can add 'timezone'=>'+01:00'
to the connection in 'config/database.php' but this has no affect. And I don't want to set the apps default timezone in 'config/app.php' because that will affect the app's own database which must be UTC.
If the database contains '2019-04-01 13:00:00', I would like $model->created_at
to return '2019-04-01 12:00:00' (UTC equivalent) by default. Likewise, if I do $model->created_at = '2019-04-01 12:00:00'; $model->save()
should save as '2019-04-01 13:00:00' in the database.
Can any one help? I'm starting to think I'll have to make a bunch of accessors and mutators for all of my datetime columns which seems like a lot of work.