First, i want to set default timezone for my website for GMT, i found this
htaccess:
php_value date.timezone "America/Chicago"
SetEnv TZ GMT
SetEnv TZ Europe/Amsterdam
(i know America/Chicago is not GMT ;) ) how should correct option looks like?
You should set date.timezone to UTC in php.ini if you have access to it, if not then do it in .htaccess like this:-
Your application will now default to using UTC as the timezone unless you specify otherwise. You can store user timezones using the strings in this list. Just allow your users to choose the correct one from a drop down.
Your application should store all date/times as UTC using either a unix or mysql timestamp. My personal preference is for unix timestamps.
When presenting dates to the user make use of the DateTime classes. For example:-
You should not use
date_default_timezone_set()
to modify timezones on the fly as this can have unpredictable side affects in your app. If that particular function is used at all, it should be only once in your app. If it appears more than that, you should consider it a code smell.