Let me explain: I'm not asking about the proper way to store a specific datetime's timezone in a database. I'm talking about timezones themselves. FOR EXAMPLE:
I have a MySQL table named 'users'. Now, on this table, I wish to have a column that contains the timezone of wherever the user lives (this is provided by the user, it will be chosen from a list). I'm working with PHP, which has a list of timezone strings like these:
List of TimeZones for America
Now, the obvious solution (at least for me) would be to create a VARCHAR column in the 'users' table, then store the timezone string used by PHP in said column.
Now that I think about it, that would assume I'll always use PHP to interact with that database table, which while true now, might not be so in the future. And (correct me if I'm wrong) PHP's timezone strings probably don't work for other programming languages, maybe other languages have their own 'constants' for timezone handling.
How would you approach saving a user's timezone preference in a DB column, then? Any ideas are certainly appreciated.
Note: the useful thing about PHP's timezones is that, even if DST is in effect, they automatically take it into account, which is awesome. So you can see my interest in using them instead of just storing a numeric offset.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…