in reply to Finding a remote time

As a general rule, when having to deal with datetimes and timezones, NEVER store a localtime. If you are going to have users / processing in multiple timezones, the sanest way to deal with everything is to store it ALL in UTC / GMT from the outset.

Storing UTC makes it trivial to display correct localised date-times in Perl / various web and other front ends / languages etc using standard libraries, and without adding the overhead of your own complex date-math for all accesses to the data.

As an aside, MySQL <= 4.1 is a PITA for saving UTC - all the time functions are localtime, and affected by the TZ of your mysql daemon.

Use this expression for a UTC now() in MySQL:

update mytable set right_now=DATE_ADD('1970-01-01', INTERVAL UNIX_TIMESTAMP() SECON +D)
To get correct localtimes in Perl / etc, just make sure that you set the TZ of the process handling the request, and the localtime functions will do the hard work for you.

Regards,

Jeff

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.
A reply falls below the community's threshold of quality. You may see it by logging in.