You can make use the TimeHelper to offset the time by user specified time zone. What u need is adding a new time_zone column in the users table just like the following example.
--MySQL
CREATE TABLE IF NOT EXISTS users (
user_id INT NOT NULL auto_increment,
name VARCHAR(45) NOT NULL,
password VARCHAR(45) NOT NULL,
time_zone DECIMAL(5,1) NOT NULL,
created DATETIME DEFAULT NULL,
PRIMARY KEY (user_id)
) ENGINE = InnoDB;
So now you can set the time zone for each user. As i am living in Hong Kong, my time zone should be GMT+8:00. so my time_zone column will be 8.0. If you are in GMT-2:30, the time_zone column will be -2.5.
It is now ready to apply the time zone in the view. First, you have to add the TimeHelper in the controller.
var $helpers = array('Time');
In the view, say, i want to offset the created field by my time zone. Add the following line.
<?php echo $time->format('Y-m-d H:i:s', $user['User']['created'], null, $user['User']['TimeZone']); ?>
Done =)
Reference: Planet CakePHP – User Timezones in CakePHP
Filed under: CakePHP Tagged: CakePHP, Time Zone
