[Pdx-pm] Windows Timezone offset
Michael G Schwern
schwern at pobox.com
Fri Oct 22 20:35:33 CDT 2004
On Fri, Oct 22, 2004 at 06:12:28PM -0700, Roderick A. Anderson wrote:
> Anyone know how to determine the timezone offset (for use in e-mail
> Date: header) in Windows?
>
> Perl knows since localtime and gmtime return two different
> (string/scalar) values but I could not determine where it came from.
> %ENV doesn't have it and a search of the perldoc.com site didn't give me
> anything useful.
Perl just calls the localtime() and gmtime() C functions and leaves them to
do the magic.
But since you have localtime and gmtime you can calcuate the offset easily.
use Time::Local;
# Convert localtime to # of seconds since epoch
my $localtime = timelocal(localtime);
# Get # of seconds different from GMT
my $offset = $localtime - time;
# Convert from seconds to hours.
print $offset/(60 * 60);
--
Michael G Schwern schwern at pobox.com http://www.pobox.com/~schwern/
Do not try comedy at home! Milk & Cheese are advanced experts! Attempts at
comedy can be dangerously unfunny!
More information about the Pdx-pm-list
mailing list