@ericknyoto You should be storing dates and times as UTC and no offset. You can then present dates and times shifted to the user’s preferred time zone.
Allow the user to store their time zone preference, just like they can a locale preference.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Guys, I need your opinions or advice or practice, how to implement this scenario. I have a server, the timezone set to UTC+2. I stored datetime as UTC+2 to database.
Now, my users are located in different timezone, for now it is in UTC+2 and UTC+8. I want to display datetime on the webapps match their timezone location. Example: Datetime stored UTC+2 2023-12-01 08:00:00 on database. When user at UTC+8, it should display on their browser the date is 2023-12-01 14:00:00 At the same time when user at UTC+2 should display 2023-12-01 08:00:00 on their browser.
I'm thinking of using Date Casting, and convert to UTC+8 if their location is on that timezone. https://laravel.com/docs/8.x/eloquent-mutators#date-casting
But, how to get client location where they access the web app? I think I can get users IP Address, and from that I can search the location based on IP address.
How to implement this on Laravel?
Thanks in advance!
Please or to participate in this conversation.