Is it important that my server has correct locale-specific timezone set?

704 views Asked by At

So my friend says that when he configures servers he ALWAYS sets their timezone as UTC. He says that this helps him in making sure that he does not have timezone issues when working with multiple servers. His code picks up the datetime from his server setting, naturally.

My question was that: if I have a machine that is located in, say, California (EST) and I set it up saying its timezone is UTC, then wont the actual time in that server be in correct?

My friend says that: If that server gets an order at 7 in the morning local time, which is 7:00 AM EST - since the server is configured as UTC (which is 4 hours ahead of EST), then the order will be saved as having placed at 11 AM UTC, which in turn means that it can be converted to any time zone as required. (Converting 11 AM UTC to EST gives 7 AM EST which is correct)

I always maintained that servers should be configured to the correct time zone. I guess I was wrong. Is it ok to have servers set up like this? Are there any drawbacks if the server timing is not locale specific?

1

There are 1 answers

0
Sandman On

My impression is the only source of weirdness is the machine is not physically located in a place which adheres to the timezone it has in its time settings. But this is only 'weirdness' and should not have any drawback (as long as the time is set accurately).

Let's consider date objects such as Date or Calendar in Java. Their implementation actually stores time as a Unix timestamp (a Long number) - Unix timestamps are basically relative to a UTC epoch ((milli)seconds passed since 1970-01-01 00:00:00 UTC). As long as timezones get correctly stored/converted between client, server & database (& vice-versa) everything should be ok. How the time gets stored in different places of the architecture is a matter of convention.

In fact, it might even help if you choose UTC as the only timezone you deal with server-side (both on the machine & in the code) (e.g. debug process, log investigations, etc.). For example log timestamps will be comparable to times logged by your business logic or db layer.

Also see this question.