OsvaldoM Posted December 28, 2010 Share Posted December 28, 2010 Hey everyone, if there is one thing i don't like about Zend Framework is that the date functions are a bit confusing and that it takes a few lines to tackle down what i really need... so i was making this line of code: $date = Zend_Date::now()->get('YYYY-MM-dd HH:mm:ss', 'Europe/Vienna'); but i realized it never gets me the timezone i wanted... This doesn't work either: $date = Zend_Date::now()->setTimezone('Asia/Kabul')->get('YYYY-MM-dd HH:mm:ss'); Do note this never throws an exception, it outputs the correct time (local) but it's unable to change the timezone of the now() constant. I've been able to change the timezone with multiple lines of code for now(), but i can't seem to get it on just one... Is it possible to do it on just one line? or is it just me being lazy? Thanks in advance for any replies... Quote Link to comment https://forums.phpfreaks.com/topic/222814-zend-framework-date-on-one-line-with-timezone-set/ Share on other sites More sharing options...
trq Posted December 28, 2010 Share Posted December 28, 2010 According to the documentation get() doesn't except a format argument, so I'm not sure why your passing it one, it's second argument is a local also, not a timezone. It's been a long while since Ive bothered with Zend, but looking at the docs it seems that .... $date = Zend_Date::now()->setTimezone('Asia/Kabul'); should be all you need. Quote Link to comment https://forums.phpfreaks.com/topic/222814-zend-framework-date-on-one-line-with-timezone-set/#findComment-1152112 Share on other sites More sharing options...
OsvaldoM Posted December 28, 2010 Author Share Posted December 28, 2010 Don't know what happened... but i tried this again today, and it worked perfectly. Probably one of those weird cookie/cache errors was making my script display the local date as i originally had it. $date = Zend_Date::now()->setTimezone('US/Eastern')->get('YYYY-MM-dd HH:mm:ss'); That works perfectly as stated by thorpe, hope this helps someone out... Thanks 4 the reply. And yeah, i format the date via the get function (You ought to never really trust Zend's docs, they are in lack of a ton of info) Quote Link to comment https://forums.phpfreaks.com/topic/222814-zend-framework-date-on-one-line-with-timezone-set/#findComment-1152129 Share on other sites More sharing options...
trq Posted December 28, 2010 Share Posted December 28, 2010 (You ought to never really trust Zend's docs, they are in lack of a ton of info) I was actually looking at the api docs and source code. Quote Link to comment https://forums.phpfreaks.com/topic/222814-zend-framework-date-on-one-line-with-timezone-set/#findComment-1152363 Share on other sites More sharing options...
recentartnews Posted January 6, 2011 Share Posted January 6, 2011 Thanks all, I have found new info here. keep the good work. Quote Link to comment https://forums.phpfreaks.com/topic/222814-zend-framework-date-on-one-line-with-timezone-set/#findComment-1155581 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.