Currently, in our Laravel application, we have the timezone set as followed.
'timezone' => env('TIMEZONE', 'Europe/London'),
All our DateTime
and timestamps
fields in our MySQL database are also stored in the Europe/London
timezone.
Our application is now going to switch over to UTC
, however as BST
is currently an hour out at the moment if we change the TIMEZONE
to UTC
in our application all our existing infrastructure will break.
The things that will break include our existing queries using time fields as they will be an hour out of sync with the records in the database.
An example of where we use time in our system within queries is as followed
Task::where('expired', '=', false)->where('expires_at', '<', Carbon::now())->get();
With the code example above tasks would be expired an hour early because UTC
is one hour behind BST
.
As changing to UTC
will be a fundamental change for a system I was hoping I could get answers to the following questions.
- Are there any resources out there that outline ways of converting a system from a local time zone to UTC?
- Instead of converting to
UTC
should I store everything inEurope/London
and then convert it for the user on the frontend? - Is there any way to easily query a database table that has multiple timezones in it?
Thanks for any help, I know this question is difficult so anything that can point me in the right direction would be greatly appreciated.