From: Robert J. <yad...@sn...> - 2006-07-05 14:53:32
|
At 12:02 PM 7/3/2006, Roger Day wrote: >Currently, the logging times are being output in GMT. What's the easiest >way to get them into localtime which for me, is BST? I was just going to say "set the timezone for the running perl process". On UNIX systems, at least, you would set the environment variable TZ. For example, my system is set to GMT time, but I can get my program to log using Eastern Standard Time (EST) by setting TZ temporarily for the perl process: bash # date Wed Jul 5 14:28:48 GMT 2006 bash # perl source.pl 2006-186/14:28:55 INFO > source.pl Starting..... bash # TZ=EST5EDT perl source.pl 2006-186/10:29:46 INFO > source.pl Starting..... However, you have to know the right timezone abbreviation -- my system does not know "BST", so it continues to use GMT for the timezone. bash # TZ=BST perl source.pl 2006-186/14:33:13 INFO > source.pl Starting..... The correct abbreviation (on UNIX systems, at least), is "TZ=GMT0BST" (that's a zero not an "oh"): date # TZ=GMT0BST date Wed Jul 5 15:46:41 BST 2006 You can set the timezone at runtime from within your perl program, instead of before running it with the following: $ENV{'TZ'} = 'GMT0BST'; Hope that helps, Rob |