This is something that can be handled with PHP and/or MySQL. With PHP you can do something like the following:
date_default_timezone_set('US/Mountain');
echo date('Y-m-d H:i:s', strtotime('now'))."\n";
date_default_timezone_set('US/Eastern');
echo date('Y-m-d H:i:s', strtotime('now'))."\n";
This will change the timezone associated with the PHP time functions. Here is a list of valid timezones: http://php.net/manual/en/timezones.php
With MySQL you have both a global timezone as well as a per-session timezone setting. If your fields are stored as timestamps (this does not work for datetime) then it will automatically convert the time stored in the field to the correct time in the set timezone. See: http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html
mysql> CREATE TABLE `time_test` (
-> `dt` datetime NOT NULL,
-> `ts` timestamp NOT NULL,
-> );
mysql> SET time_zone = '-2:00';
mysql> INSERT INTO `time_test` SET `dt` = NOW(), `ts` = NOW();
mysql> SELECT * FROM `time_test`;
-- You will notice that the times will be the same, now change the timezone
mysql> SET time_zone = '+8:00';
mysql> SELECT * FROM `time_test`;
-- Now notice that the value of the timestamp has moved forward 10 hours, while the datetime has remained the same.
All this being said, now you have two options for how to control what values are stored, depending on which median you would prefer.
My initial thoughts are that you could implement an event handler for ‘beforeAction’ in your base controller. If the user is logged in, read their preferred timezone from their config and set it in MySQL or PHP. You could also create a new child class of application that, upon initialization does all this checking and set the related item.
Keep in mind that with both these method you need to store everything in terms of timestamps. PHP and MySQL are both smart enough to generate the same timestamp, regardless of the timezone that is used:
date_default_timezone_set('US/Mountain');
$ts = strtotime('now');
echo $ts.' => '.date('Y-m-d H:i:s', $ts)."\n";
date_default_timezone_set('US/Eastern');
$ts = strtotime('now');
echo $ts.' => '.date('Y-m-d H:i:s', $ts)."\n";
---------------
Output:
1260599676 => 2009-12-11 23:34:36
1260599676 => 2009-12-12 01:34:36
Storing items as a date string, in either case, will probably ruin the ability to easily convert between timezones.
Does that help?