It's based on two tables..
ISO3166 (country names) + timezone table, called tbl_timezone.
You let your users select a country from a list you generated from iso3166 table. Then you use the <option value=<2 char iso3166 code>"..
When the user then browses the page, run a query and check if the user has he field TZ set, in the db. if it's not set, run a natural join between user_table, iso3166 table and the timezone table.
If mysql_num_rows > 1, this means the country has more than one timezone. Then you generate a list of the availible timezones and let the user choose.
That then updates the field TZ in the user table.
The next time the page refreshes, you get the TZ value (for example: 'Asia/Bishkek') and use the putenv("TZ='Asia/Bishkek');
there is no TZ in the mysql db, so you will ned to use addtime function, with the difference from old_TZ - new_TZ
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.