views:

178

answers:

1

I have a ZF app and am saving times as UTC in MySQL db. When I retrieve, them I'd like to tell Zend_Ddate that they are UTC rather than the timezone set in php.ini of 'America/Los Angeles'.

Currently, I'm instantiating like this:

$date=new Zend_Date($item['created_on_utc'],Zend_Date::ISO_8601,'en_US');

but feel like there should be a way to tell Zend_Date that is a utc Date. How would I do that?

thanks

+1  A: 

Hi,

try the following:

date_default_timezone_set — Sets the default timezone used by all date/time functions in a script

date_default_timezone_set('Etc/UTC');
henchman
+1, this is best set in your bootstrap. In fact, with E_STRICT enabled, PHP will complain whenever you are using a time function relying on the timezone.
Gordon
this was already done index.php script. the issue is that I'm saving in UTC with locale associated with that save (in case user changes his / her locale at a future point). The issue is how do I decrement the 8 hrs from UTC to America / Los Angeles. It seems like I should be able to tell Zend_Date, you're getting UTC and I want it to be Pacific time zone
timpone