Perl question

Victor Odhner plug-devel@lists.PLUG.phoenix.az.us
Mon May 21 19:18:01 2001


Hi, Carl.

The point you're missing is that in the Unix world, all time is Coordinated Universal Time, formerly known as GMT.  When you synchronize your time against another server, the two machines are agreeing on what time it is in Greenwich.  So all Unix machines worldwide are running on the SAME time,
except for any error that may creep in (which is a lot on most Intel-type boxes).

The "localtime" library function translates that into a localized time based on the current value of your TZ environment variable.  For us here in Arizona, for example, it effectively subtracts seven hours from the seconds-from-the-epoch time that you get from the time() function, and displays the
time accordingly.

So to get "localtime" to display the time for a specific time zone, just set the TZ value of your process to the time zone in question, then use "localtime".  It doesn't know or care what time zone you're really in, or what server you set your time from.

But your question was ambiguous, so Kevin gave you two answers.  If you synchronize all the related machines together, that will help them agree to the second.  If all of them use the same TZ value when displaying the time, that will help them agree to the hour.

Note again what Kevin said:  You can set $ENV{ TZ } to "EST" or "US/Eastern".  I don't know what US/Eastern is, but EST does not adjust for daylight savings.

Good luck,

Vic

Carl Parrish wrote:
> 
> Okay I tend to use this a lot.
> 
>     use Time::localtime
>     $date = localtime(time);
> 
> But now what if I don't want to use the local time. What if I want to use the time of a MIT server. Or I want my server to use MST but I want the
> date set to EST. What would I use to grab this???