mardi 1 décembre 2015

MySQL & PHP - How to convert date, time, and timezone when stored separately

In our application, we're currently storing date, time, and timezone separately. The date field is optional, which is why we have everything separated. For the user interface, they will specifically select a date, a time, and then a timezone. Everything is currently stored in UTC and the timezone would be an ID, which references another lookup table.

The way I understand and see it, we can display the date and time the user specified, simply by showing all three of those values without having to adjust anything. If they entered 11-30-15 6:00PM PST, that's what they'll see, formatted however we see fit.

  • Are there any immediate issues anyone can think of doing it this way so far?
  • How should I handle the time conversion? At some point in the system, it needs to understand the actual time. The system time is UTC, but if some work needs to be performed at 11:00AM PST, then it needs to know that. I'm wondering if there is an issue storing the time as UTC, but having them specify a timezone that is different. For example, the time is supposed to be PST, but is stored as UTC.

I am using Laravel with Carbon, just to provide more information. Any feedback would be great!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire