Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Say I'm having a multiplayer RTS game. There's a main server for each individual game and several clients connected to it. All packets are sent to server first and then server retransmits them back to clients.

Say Server is located in one time-zone and all of the clients are in different time-zones. ClientA send a text message in chat at 12:03, what times should be stamped for other clients? Should his message be uniformely timestamped by Server (12:02) or each client should timestamp the message whenever it is recieved (12:04, 16:04, 03:03, etc..). Bear in mind, that all the messages are to be in the same order on all clients, server takes care of that.

So thats the question - use local time for each client or use global server time to timestamp chat messages?

share|improve this question

1 Answer 1

up vote 13 down vote accepted

Since you use a central server, the server will keep track of game events and clients will sync their state with the server state. When a message is received by the server at 12:02, the message should show up at the client as being sent at 12:02. However, when dealing with different timezones, you want the client to display local times. This is more convenient and natural to read for the user, as he does not need to think about all the time differences.

The approach I would recommend is timestamping each message in UTC (a method for creating an UTC timestamp is present in almost every class or system library). When the client has to display the message time, the time is converted to the local time zone before being rendered to the screen.

share|improve this answer
    
Definitely local timezone for display. People get unbelievably confused by timezones. –  Tim Holt Jun 20 '12 at 4:00
    
And you may provide a checkbox in options to show each users actual time, so they are aware of nolifers. –  joltmode Jun 20 '12 at 8:59
    
If there is a case when knowing the server time/time zone can be useful, then let clients know the server time (with the same checkbox approach as stated by @Tom). Using UTC is fine, but in some cases you'd want to know, for example, if friday night for you means saturday morning for the server. –  Darkwings Jun 21 '12 at 12:28
    
@Darkwings, and with huge games, for example, WoW - a lot of events start servertime, and it's good to know the difference. –  joltmode Jun 21 '12 at 21:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.