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

swapnilnandgave's avatar

User Selected Date with different Timezones

How would we manage multiple timezone for user selected date? for example, As a user, I am booking for 5th March 2022 from India('Asia/Kolkatta' timezone) and now I am accessing same information from different timezone('America/NewYork'). Date(5th March 2022) has been selected by me. How would I manage such scenarios for user selected dates?

0 likes
1 reply
fylzero's avatar

@swapnilnandgave My strategy has always been to grab and store the user's native timezone on the user table via a timezone string field.

You can use Moment tzGuess to figure out a default setting for the user on sign up. https://momentjs.com/timezone/docs/#/using-timezones/guessing-user-timezone/

Once you have the user's timezone stored, make sure any input from the user is converted to UTC and stored in the database.

When displaying time-related info to the user, convert from UTC to their stored users.timezone setting. This can be done using a custom cast in Laravel or handled on the front-end.

This will ensure all time data is stored in UTC and can be converted to any user's timezone.

Please or to participate in this conversation.