How to use Zend_Date to print a time in a specific timezone
In my app I use Zend_Date. I have set date_default_timezone_set('UTC') because internally and in the database I only want to have UTC times.
For users I want to display it in their local time. What is the easiest way to do this? Let's say, I have in the view $user->timezone and $date, where $timezone is 'Europe/开发者_如何学JAVAHelsinki' and $date is a Zend_Date.
This should be better documented in the manual, as it's a pretty common use case. Fortunately it's nice and easy:
$date->setTimezone($user->timezone);
echo $date->get(Zend_Date::TIME_SHORT); //prints in user timezone
精彩评论