You can use the wonderful DateTime module for this:
use strict; use warnings; use DateTime;
When I run this with TZ = "/ usr / share / zoneinfo / Europe / Paris", I see:
Current time: 2010-04-19 20:09:03 CEST
How to extract timezone data from a user file: A quick solution is to save this user's TZ configuration in a separate file (which may be the source of .bashrc), and you can manually analyze it in CGI (however this gets into another topic: what is the best way to store configurations for each user for CGI?)
# /home/<user>/.tz should have the content: export TZ="/usr/share/zoneinfo/timezonename" open(my $tz_fh, "/home/${user}/.tz"); chomp(my $tz_data = <$tz_fh>); close $tz_fh; (my $tz_path) = $tz_data =~ m/^export TZ\s*=\s*"(.+)"$/;
Ether source share