Welcome Guest, Not a member yet? Register   Sign In
Timezone handling suggestions with CI4

I'm curious what others do to handle timezone issues with CI4. Conceptually, I am currently of the opinion that dates should be stored as UTC. Front end should display whatever timezone is appropriate for the user. For the sake of this discussion, let's assume 'America/Chicago' is the timezone of the user.

I am taking advantage of CI4 Entities, which is super helpful for many of the tasks I need. CI4 has a config setting in the App config class called $appTimezone that is used to display dates. Conceptually, should I treat the CI4 config value $appTimezone as synonymous with "front end timezone", or should $appTimezone be the same as my storage timezone? So, in this scenario, should $appTimezone be 'America/Chicago' or 'UTC'?

This decision will dictate where in the process of handling user input that I need to make timezone conversions. I sort of suspect the intention of $appTimezone is to be the "front end timezone." If that is correct, then that means I will have to make some clever coding to extend the default Model methods for saving Entities. There seems to be no obvious way to tell CI4, "I want to store all dates in UTC." On the other hand, if I make the $appTimezone 'UTC', then I will have to remember to intercept all $_POST dates and remember to convert them from 'America/Chicago' to 'UTC' (unless there is some clever way to handle this with Entities). Anyway, I'm hoping someone with more experience has a good suggestion for how best to handle this issue in CI4.

Thank you so much for any suggestions.

Messages In This Thread
Timezone handling suggestions with CI4 - by never2ice - 04-29-2020, 03:12 PM

Theme © iAndrew 2016 - Forum software by © MyBB