View Full Version : Time Zone Environment variable

05-24-2003, 12:18 AM
I am operating a dynamic calendar feature for my client. I am having to hardcode the timezone for the Westhost server because there does not appear to be an environment variable for it. Are there plans to provide one in Westhost 2, and are there general plans to enhance the environment variable list in the future? Westhost's current list is small compared to others.


WestHost - CSimiskey
05-28-2003, 12:36 AM
We may be better able to understand what you need by knowing what you are doing currently. If you can provide us more details we can probably offer potetnial solutions to the difficulties you are having. I am unaware of any problems with our current setup and would venture to guess that the problem likely lies with the script itself, not the operating system

05-28-2003, 05:53 AM
I can understand your "say what?". The problem I am describing is not in the Perl script. The problem is that the local time on your machine (Chicago) is different from the local time where I script results appear (SC). The script manages an announcement bulletin board on a public school website where entries age and drop off as time progresses daily. In order to age an announcement correctly, the script has to do so in terms of the local time, i.e., SC time, not server time, and be able present the time to the users as such. Hence, knowing how many hours by which to adjust the local time based on the server's own time zone is essential to the task.

Many servers maintain an Environment Variable which gives the time zone of the server. Some of them keep it in GMT plus or minus value. For example, SC is GMT -5. Chicago would be GMT -6. There are other methods. Here is the hunk of script which calculates the time. The Perl module is Date::Manip. The point is, I do not want to have to hard code "CST" in the TZ conversion routine. I know where I live; I may not know where the server lives. What I need is an Environment Variable (ENV hash) which gives the local Time Zone string.

# date calculations
my @format1=('%A');
my @format2=('%B');
my @format3=('%Y');
my @format4=('%d');
my @format5=('%dt');

# gives full date time in EST
# our server is in Chicago, so "00:00 today" is really 1 a.m. in SC
# this just keeps everything consistent by a whole day
my $now=&ParseDate("00:00 today");
# gives full weekday name
my $weekday1=&UnixDate($now,@format1);
# gives full month name
my $month1=&UnixDate($now,@format2);
# gives full 4-digit year
my $year1=&UnixDate($now,@format3);
# gives day of month for today as 01-31
my $day1=&UnixDate($now,@format4);

WestHost - CSimiskey
05-28-2003, 12:00 PM
So you are looking for information such as what you can see using server side includes something like this I created (named env.sht):

<!--#echo var="DATE_LOCAL"-->
<!--#echo var="DATE_GMT"-->
<!--#printenv -->

Note that the #printenv does include the date_local and gmt in it as well, but seperating them out makes for much easier reading. Unfortunately not being a perl programmer I couldn't really say how to get those variables into your script, but they are there for your use.