mysql - Storing timezone in a database -
i using mysql , php , need store timezone in db. spent bit reading on it, , seems need use america/los_angeles
, , not pst
, pacific standard time
, pst8pdt
, +02.00
, etc.
do store whole america/los_angeles
string, or there sort of integer id such https://stackoverflow.com/a/11580459/1032531 describes c#? if string, maximum number of characters?
the timezone strings america/new_york
refer entries in so-called zoneinfo data base. read this. https://www.iana.org/time-zones it's presently maintained internet assigned numbers authority. changes lot, because maintainer scrambles keep changes daylight saving rules , other temporo-political stuff.
on unix-like systems entries stored in filesystem directory hierarchy, , not code number.
you asked:
do store whole
america/los_angeles
string
yes.
is there sort of integer id it?
no, not if want application , data base future-proof. there time_zone_id in part of mysql holds zoneinfo data, nobody has made promises keeping numbers unchanged.
the longest string in current (2015g) data base "america/argentina/comodrivadavia". it's 32 characters long. makes sense use varchar(64)
storing information never run out.
by way, wordpress offers user picklist (drop down list) of available time zone names, , stores user's choice text.
Comments
Post a Comment