vic vance Posted February 28, 2012 Share Posted February 28, 2012 Hey, I have just recently coded a forum and my topics are ordered by date. This means if there is a topic at 4pm and then there is another topic made at 4:01pm the topic which was posted at 4:01pm will be listed at the top. I know how to add timezones but there is bit of a problem, if person from the UK posts a topic and his/hers timezone is set to: date_default_timezone_set('Europe/London'); this means the time at which the topic was posted will be 20:36pm (Just a randome time example). However if someone posted a topic from america/los_angeles one hour before the one above his/her time will be 11:36 am. Even though this topic was posted one hour before the UK post. The UK topic will override it because it is 8:36pm. In fact, all UK topics will show up at the top and all the america/los_angeles topics will show bellow. How do I slove this problem? I just don't get it even tough I looked online. Please help, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/257945-dates/ Share on other sites More sharing options...
litebearer Posted February 28, 2012 Share Posted February 28, 2012 Not 100% positive but perhaps saving as GMT might be an approach (old man musing (NOT Amusing simply musing)) Quote Link to comment https://forums.phpfreaks.com/topic/257945-dates/#findComment-1322119 Share on other sites More sharing options...
kicken Posted February 28, 2012 Share Posted February 28, 2012 The date/time values you store in your database should all be based on the same timezone, UTC works well. Then you just format them for the user's proper timezone when you display them. Quote Link to comment https://forums.phpfreaks.com/topic/257945-dates/#findComment-1322126 Share on other sites More sharing options...
vic vance Posted February 29, 2012 Author Share Posted February 29, 2012 The date/time values you store in your database should all be based on the same timezone, UTC works well. Then you just format them for the user's proper timezone when you display them. I see what you saying, can you please show or explain an example? I am just cannot fully understand. :< I have a dates colum in my forumm, at this moment I was just testing it and it is vanchar 30. All my dates are stored as: // Prints something like: Monday 8th of August 2005 03:12:46 PM echo date('l jS \of F Y h:i:s A'); so all my dates are like the printed example above echo. This is just a default time/date I have no date_default_timezone_set. Quote Link to comment https://forums.phpfreaks.com/topic/257945-dates/#findComment-1322242 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.