Perl question

Carl Parrish plug-devel@lists.PLUG.phoenix.az.us
Mon May 21 20:15:02 2001


Okay apparently I still didn't give enough information. I don't want the 
actually system time on these machines to change. They all have 
different TZ settings (I just learned what that is thank you very much). 
This is what I want to do. Regardless of what the local time is I want 
my application on all of these machines to read EST. So is there some 
way for to set the TZ (or some other variable ) to EST for the 
*application* while leaving everything else on the box to the current 
local time?

Thanks for all of you help.

Carl

Victor Odhner wrote:

>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???
>>
>_______________________________________________
>PLUG-devel mailing list  -  PLUG-devel@lists.PLUG.phoenix.az.us
>http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-devel
>