I store a date/time in my database that is UTC. I’m working to add conversion of this once a user selects a timezone so it shows local time for them. Basically the user selects from a form:
<select name="DropDownTimezone" id="DropDownTimezone">
<option value="-12.0">(GMT -12:00) Eniwetok, Kwajalein</option>
<option value="-11.0">(GMT -11:00) Midway Island, Samoa</option>
<option value="-10.0">(GMT -10:00) Hawaii</option>
...
I can make the option value anything I want but an easy to remember one is as above. What data type would I use for mysql? Does it really matter in this case? Would TINYINT do? Maybe using an ENUM would be a good idea?
Any suggestions would be appreciated.
The scheme you’re proposing (storing time zones as an integer offset from GMT) may fail for the following cases:
For full time zone support, I’d recommend using the
zoneinfodatabase and storing time zones as strings (e.g, “America/New_York”).