![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| US timezone changes Mar 2007 | hcclnoodles | SUN Solaris | 5 | 03-09-2007 08:46 PM |
| Timezone | oss | UNIX for Advanced & Expert Users | 7 | 10-19-2005 11:20 PM |
| timezone | eddyvdv | UNIX for Dummies Questions & Answers | 1 | 04-08-2002 02:46 PM |
| Timezone | Novisern | UNIX for Dummies Questions & Answers | 5 | 03-28-2002 04:13 PM |
| Timezone | ortsvorsteher | UNIX for Dummies Questions & Answers | 6 | 03-07-2002 01:08 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
| Forum Sponsor | ||
|
|
|
|||
|
Quote:
use this command " date +%z " |
|
|||
|
Straight shell does not do what you need. try perl:
Code:
#!/bin/ksh
get_tz()
{
perl -e '
use POSIX;
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)=localtime(43200);
($sec1, $min1, $hour1, $mday, $mon, $year, $wday, $yday, $isdst)=gmtime(43200);
$diffmin=$min - $min1;
$diff=$hour - $hour1;
printf "%s%02d%02d\n", ($hour1 <= $hour)?"+":"-", abs($diff), abs($diffmin);
'
}
mytimezone=$( get_tz)
echo "my time zone is: $mytimezone"
|
|
|||
|
You can reasonably expect a system to support POSIX specifications for the date command. POSIX does not specify a %z. That is a GNU extension. GNU date is a good program, but if he is on a multiuser system, getting GNU date installed may be neither practical nor allowed.
GNU date is clearly not what the OP is now using. |
|||
| Google The UNIX and Linux Forums |