问题
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/Helsinki' and $date is a Zend_Date.
回答1:
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
来源:https://stackoverflow.com/questions/1550432/how-to-use-zend-date-to-print-a-time-in-a-specific-timezone