Syntactic Confectionery Delight | |
PerlMonks |
Re: Finding a remote timeby jaa (Friar) |
on Jul 17, 2006 at 20:37 UTC ( [id://561848]=note: print w/replies, xml ) | Need Help?? |
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: 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
In Section
Seekers of Perl Wisdom
|
|