Franklin wrote:
> Hello:
> My operating system is freebsd and its time is GMT time which I can't
> change. How can I write a perl script to get the exact
> time(Hour,minute,second) and change it to US ET?

As John said, the internal clock is always UTC. On FreeBSD, you use the
tzsetup(8) program to set the default time zone. If you're in US Eastern
time zone, your sysadmin should go ahead an set this. Once set, Perl's
localtime() function will return Eastern time, while gmtime() will return
UTC.

If you want to temporarily override the default time zone, you can set the
TZ variable.

Here's an example from my FreeBSD system (default time zone is
America/New_York):

   $ perl -de0
   main::(-e:1):   0
   DB<1> x scalar localtime
   0  'Fri Sep 17 08:21:30 2004'            <--- default (Eastern) time
   DB<2> $ENV{TZ}='America/Los_Angeles'     <--- set TZ to a different time
zone

   DB<3> x scalar localtime
   0  'Fri Sep 17 05:21:46 2004'            <--- Pacific time
   DB<4>

To see all the time zone names, look at the file
/usr/share/zoneinfo/zone.tab

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to