Home > Software design >  Best practice for maintaining current Timezone in Database - Laravel
Best practice for maintaining current Timezone in Database - Laravel

Time:01-28

I store the timezone in the database upon login determined by the users IP address. This works great. The problem is:

Let's say someone logs in with remember me on, and they are in America/Los_Angeles. But then they happen to travel to somewhere else and they're still logged in... The timezone won't update unless they log out and back in

So my question is... What would be best?

Option A: Each request, update timezone in database

Option B: Ask for Timezone on registration (autofill based on IP), and then let the user change their timezone in user settings

Option C: check timezone with every request and if it doesn't match, show a message asking if they want to update their timezone to their current one

CodePudding user response:

The question seems to be concerned more with UserExperience, rather than Laravel implementation.

All the options you mentioned are valid.

Normally for things like this you'd want to consult your users with it, it makes for a better experience, as well as respects the user's right to choose.

I'd recommend option B or C, since they give the user the option. (Useful for cases where someone is using VPN for example, where the timezone can change frequently, but the user wants to work on his own prefered timezone).

But remember, this is more of a preference answer rather than a standard answer.

  • Related