Hi, Are you using MySQL and TIMESTAMP for date columns definition? If yes, you don't need to do much with Zend Date. You just must ensure that all users are dealing with their local date/time, and correct MySQL @@session.time_zone variable.
More infos under: http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html -- Regards, Vladas Diržys On Fri, Oct 9, 2009 at 13:22, MarkW508 <[email protected]> wrote: > > Hello everyone, > > I've never used the Zend Framework before, and starting a new application I > have a particular concern surrounding the best way to store dates. I really > want to make sure that what I'm thinking is the best way to go about it, > since it could be difficult to change later on. > > I'm expecting in my application users from different timezones, and it's > important that the users see the correct timezone. > For example, if "Joe" posts a message at noon in Australia, other users in > Australia should see "Posted by Joe at 12pm" - but users in England should > of course see "Posted by Joe at 2am" (or whatever). > > I was thinking the best way to go about this would be to first of all ask > users when they register what timezone they're in by allowing them to > choose > from the list PHP provides. Then in the bootstrap, using > date_default_timezone_set to set this. > We'll represent all dates with an object of Zend_Date. > When we save a date in the database we will use > Zend_Date::setTimezone('UTC') - so all the timestamp will be in UTC - and > then Zend_Date::get() to get the timestamp to save. So all timestamps in > the > database will be in UTC. > Then when we retrieve a date from the database, we'll use $date = new > Zend_Date($timestamp, 'UTC') - from the tests I've done, it looks like this > will return a time in the timezone based off the current timezone which we > can then display to the user. > > Now my question is firstly: will that work? Can anyone see any problems > with > doing that? But also: is this the best way to do it? Are there any other > ways anyone can recommend? Like I say, I really want to start with the best > practice to save headaches later - any advise would be greatly appreciated. > > Thanks :) > -- > View this message in context: > http://www.nabble.com/The-best-way-to-store-dates-tp25818798p25818798.html > Sent from the Zend Framework mailing list archive at Nabble.com. > >
