Perl: use POSIX (strftime); my $tz = strftime("%z", localtime); $tz =~ s/(\d\d)(\d\d)/$1/; Shell: date +%z|sed 's/[0-9][0-9]$//'