1
\$\begingroup\$

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?

\$\endgroup\$

1 Answer 1

13
\$\begingroup\$

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.

\$\endgroup\$
4
  • \$\begingroup\$ Definitely local timezone for display. People get unbelievably confused by timezones. \$\endgroup\$
    – Tim Holt
    Jun 20, 2012 at 4:00
  • \$\begingroup\$ And you may provide a checkbox in options to show each users actual time, so they are aware of nolifers. \$\endgroup\$ Jun 20, 2012 at 8:59
  • \$\begingroup\$ 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. \$\endgroup\$
    – Darkwings
    Jun 21, 2012 at 12:28
  • \$\begingroup\$ @Darkwings, and with huge games, for example, WoW - a lot of events start servertime, and it's good to know the difference. \$\endgroup\$ Jun 21, 2012 at 21:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .