Jump to content

Dates?


vic vance

Recommended Posts

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.

 

 

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.