How to use Zend_Date to print time in a specific timezone

In my application I am using Zend_Date. I set date_default_timezone_set ('UTC') because internally and in the database I only want UTC time.

For users, I want to display them in their local time. What's the easiest way to do this? Let's say I have $ user-> timezone and $ date in my view, where $ timezone is Europe / Helsinki and $ date is Zend_Date.

+2


source to share


1 answer


This should be better described in the manual as it is a fairly common use case. Fortunately, this is nice and easy:



$date->setTimezone($user->timezone);

echo $date->get(Zend_Date::TIME_SHORT); //prints in user timezone

      

+3


source







All Articles