How to handle time slots for each chat message

I am creating a web chat application using ASP.NET. I have a chat system that works when messages are sent and passed back to clients. But there was something that I noticed but never thought it would be a problem. I'm from England and the chat app sits on servers in America and notices when the message was displaying the time, the times were in America's time zones. How do I set up time intervals to match the user's timezone.

+3


source to share


1 answer


Save data in UTC format. Is always. So instead of storing, GETDATE()

store GETUTCDATE()

(or SYSUTCDATETIME()

in SQL Server 2008+).



This makes it easy to convert all chat time to whatever time zone the user is in. And ASP.NET has many features to help you with this transformation if you don't want to do it in SQL.

+5


source







All Articles