I have an application that uses Zend_Date to display dates. Zend_Date instances are created using datetime data from MySQL, user input, and current date.
I would like my users to be able to specify their time zone and all the dates that will be displayed in their local time.
My code currently works as follows:
$date = '2009-01-01 10:30:00'; $date = new Zend_Date($date, Zend_Date::ISO_8601); echo $date->get(Zend_Date::TIME_MEDIUM); //10:30:00 $date->setTimezone('Australia/ACT'); echo $date->get(Zend_Date::TIME_MEDIUM); //21:30:00
This works, but a setTimezone call is required for each date. Is there an easier way to manage time zones?
I also consider using SET time_zone with MySQL to return adjusted data from MySQL. Then I will only need to configure the dates created in PHP scripts for time zones.
I would like to hear the best way to handle this if someone has experience.
thanks
date php zend-framework
David Snabel-Caunt
source share