I built something like chat service in a website, and when a user send a message or receive a message I show for him when the message sent or received.
I save all messages in the DB.
Now the problem came from: the server which hosts the website is in USA, and some users come from different countries, with different time zones.
So I the user sent a message and he was in Egypt for example, he will see that his message sent 6 hours ago not now as he just sent 🙂
I want to know how website such as facebook, twitter and stackoverflow solve this issue.
Notes:
– I am not asking the user about his timezone or country while registration.
– I am using ASP.Net MVC.
– I am using timeago jquery plugin to show nice formated dates.
I’d guess the best way would be to collect a DateTime value from your user’s PC whenever they submit text.
From that, you should be able to determine what time zone they are in based on the number of hours difference.
Then, whenever you display the time stamp in your application, add or subtract the number of hours difference.