views:

23

answers:

2

Hi,

I wonder if, when you call something like that

time();

it returns the timestamp relatively to your time zone setting or to UTC ? For example, when syncing two agents, that must be important to take care of it, doesn't it ?

+1  A: 

In python e.g. time.time

[r]eturns the time as a floating point number expressed in seconds since the epoch, in UTC.

The MYYN
+1  A: 

You are absolutely right that the time needs to be adjusted for users at different locations.

  • First, you need to be able to know what timezone each agent is in, which you cannot really guess, but ask the client to include the info in the request.
  • Then, depending on the language you are using, you can either call some function with the timezone offset as the parameter to get the adjusted time, or calculate the time yourself by adding 60*60*1000*offset milliseconds to the UTC time.
coolnalu
Just a comment, as this might not be clear to everyone:Store (on disk, database, etc.) all times in UTC, and only convert them to local timezones (e.g. follow this answer) when displaying them to users.If you don't, you're asking for trouble – especially if your local zone uses daylight savings time, it will mess up your syncing.Anyway, time() and "timestamps" generally refer to UTC.
Petr Viktorin