fosterjr
20th January 2005, 14:51
In HP-Unix (and I assume most flavors of Unix), the TZ environment variable can be set as a user logs into the system, thus displaying the time correctly for each timezone.
Is there a similar environment variable or configuration in Windows NT/2000/etc that would set TZ per user when they log into the server? If so how can it be done in a commandline or batch file type process?
rdbailey
20th January 2005, 16:37
The timezone environment variable can be set in any batch file (perhaps attached to the user login script) with the following syntax:
set TZ=tzn[+|-]hh[:mm[:ss] ][dzn]
tzn - the Time Zone Name (i.e. Eastern Standard Time is 'EST')
hh - hour difference from GMT (EST is a 5 hour difference)
mm - minutes difference (in case they are in a "half-hour" time zone such as in Newfoundland)
ss - seconds difference (I am not aware of this actually being used anywhere, but it is there if you need it)
dzn - used if that time zone observes day-light savings time (i.e. Eastern Daylight Time = 'EDT')
So, if I were to set this for a user in my time zone I could use:
set TZ=EST5EDT
This variable could then be polled for later use.
To make things easier, you could just create your own environment variable and assign a number to it (i.e. set MYTIME=5). You could then do your own math when polling the variable.
Each user profile in Windows NT/2000/2003 allows you to set up a user login script. That script could contain your environment variable setting so each login would set their time zone.
I am not sure of your exact situation so I can't really make any suggestions of how to proceed, but this might help with the environment variable part of the problem.