Question: 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.

Answer: 
If the timestamp is stored as [Coordinated Universal Time (UTC)](http://en.wikipedia.org/wiki/Coordinated_Universal_Time), then all you should have to is format the value from the database according to the user's local timezone.

For example, assuming that the timestamp from the database is in milliseconds (e.g. 1309365893296), then in javascript, you can do the following to convert it to the user's local timezone:

```
var localtime = new Date(1309365893296);

```
What you need to do is store all of your timestamps using `DateTime.UtcNow`

When you go to display the time to the user, you can use `.ToLocalTime()` off of your variable to convert it to each users' local timezone.