php - Proper way to store a timezone in a database? -


let me explain: i'm not asking proper way store specific datetime's timezone in database. i'm talking timezones themselves. example:

i have mysql table named 'users'. now, on table, wish have column contains timezone of wherever user lives (this provided user, chosen list). i'm working php, has list of timezone strings these:

list of timezones america

now, obvious solution (at least me) create varchar column in 'users' table, store timezone string used php in said column.

now think it, assume i'll use php interact database table, while true now, might not in future. , (correct me if i'm wrong) php's timezone strings don't work other programming languages, maybe other languages have own 'constants' timezone handling.

how approach saving user's timezone preference in db column, then? ideas appreciated.

note: useful thing php's timezones that, if dst in effect, automatically take account, awesome. can see interest in using them instead of storing numeric offset.

and (correct me if i'm wrong) php's timezone strings don't work other programming languages

ok, will. :)

php implements iana/olson/tzdb/zoneinfo database (lots of names same thing). closest thing there industry standard, , it's implemented in every programming language , platform.

the os doesn't support natively microsoft windows, because microsoft maintains own time zone database. platforms windows-centric, .net, there libraries have use if want support style of timezone.

read more in timezone tag wiki, or on wikipedia.

so yes - store timezone id string varchar. that's best thing do.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -