I am writing a bash script which needs my time zone location like
"America/Chicago" .
Is there a command I can use to fetch timezone location.
google has worn my eyes out. Did find assembly and c code but
is a bit much.
|
|
0
|
|
|
|
Reply
|
BitTwister2 (1227)
|
10/25/2009 12:17:35 AM |
|
"cat /etc/timezone" for the "system" timezone.
$TZ for the user's timezone (if set).
--
John Hasler
jhasler@newsguy.com
Dancing Horse Hill
Elmwood, WI USA
|
|
0
|
|
|
|
Reply
|
jhasler (209)
|
10/25/2009 12:34:40 AM
|
|
Bit Twister wrote:
>
> I am writing a bash script which needs my time zone location like
> "America/Chicago" .
>
> Is there a command I can use to fetch timezone location.
>
> google has worn my eyes out. Did find assembly and c code but
> is a bit much.
$ cat /etc/timezone
Europe/London
This is on Ubuntu.
|
|
0
|
|
|
|
Reply
|
pk (424)
|
10/25/2009 12:36:57 AM
|
|
Bit Twister <BitTwister@mouse-potato.com> writes:
>I am writing a bash script which needs my time zone location like
>"America/Chicago" .
>Is there a command I can use to fetch timezone location.
No. If the system is set up properly, /etc/localtime is a copy, not a link (since
a link would probably be broken on bootup before /usr is mounted).
However, you can probably to do
date
which will tell you in short form (eg PDT). On the other hand that could well be
ambiguous.
Perhaps you should tell us why you need that, rather than say the displacement
from UTC which is also easy to get.
date -R,
the 6th field gives the displacement from UTC.
Your particular distribution might have the information in say
/etc/sysconfig/clock
(ZONE=) or in an environment variable
>google has worn my eyes out. Did find assembly and c code but
>is a bit much.
|
|
0
|
|
|
|
Reply
|
unruh-spam (2581)
|
10/25/2009 12:37:01 AM
|
|
On Sun, 25 Oct 2009 00:37:01 GMT, Unruh wrote:
> Perhaps you should tell us why you need that,
I did tell you. :)
Details: I am writing an automated install script
$ wc -l install_vtiger
1195 install_vtiger
for the vtigercrm (http://vtiger.com/) package on Mandriva Linux 2010.0
I need to modify application's php script to set zone.
> Your particular distribution might have the information in say
> /etc/sysconfig/clock
> (ZONE=) or in an environment variable
We have a winner. Thank you very much.
Proof:
. /etc/sysconfig/clock
echo $ZONE
|
|
0
|
|
|
|
Reply
|
BitTwister2 (1227)
|
10/25/2009 1:18:13 AM
|
|
On Sun, 25 Oct 2009 01:36:57 +0100, pk wrote:
> Bit Twister wrote:
>
>>
>> I am writing a bash script which needs my time zone location like
>> "America/Chicago" .
>>
>> Is there a command I can use to fetch timezone location.
>>
>> google has worn my eyes out. Did find assembly and c code but
>> is a bit much.
>
> $ cat /etc/timezone
> Europe/London
>
> This is on Ubuntu.
On Mandriva Linux
$ cat /etc/timezone
cat: /etc/timezone: No such file or directory
$ cat /etc/sysconfig/clock
UTC=true
ARC=false
ZONE=America/Chicago
|
|
0
|
|
|
|
Reply
|
BitTwister2 (1227)
|
10/25/2009 1:21:15 AM
|
|
John Hasler <jhasler@newsguy.com> writes:
>"cat /etc/timezone" for the "system" timezone.
Does not exist in Mandriva. Ie, this is a very distro dependent solution.
>$TZ for the user's timezone (if set).
|
|
0
|
|
|
|
Reply
|
unruh-spam (2581)
|
10/25/2009 1:42:39 AM
|
|
On Sun, 25 Oct 2009, in the Usenet newsgroup comp.os.linux.misc, in article
<slrnhe79ql.k8f.BitTwister@wcooker.home.test>, Bit Twister wrote:
>Unruh wrote:
>> Your particular distribution might have the information in say
>> /etc/sysconfig/clock
>> (ZONE=) or in an environment variable
>
>We have a winner. Thank you very much.
and again, we may not - there is no standard. See
http://www.pathname.com/fhs/
The Linux Standard Base (http://www.linuxbase.org/spec/) does define
a pair of C variables
__timezone -- global variable containing timezone
__tzname -- global variable containing the timezone
but that's about it for standarization.
>Proof:
> . /etc/sysconfig/clock
> echo $ZONE
Doesn't work on non-RedHat derived systems, as already demonstrated by
others.
Old guy
|
|
0
|
|
|
|
Reply
|
ibuprofin2 (2555)
|
10/25/2009 4:09:44 PM
|
|
On Sun, 25 Oct 2009 11:09:44 -0500, Moe Trin wrote:
> On Sun, 25 Oct 2009, Bit Twister wrote:
>>Unruh wrote:
>
>>> Your particular distribution might have the information in say
>>> /etc/sysconfig/clock
>>> (ZONE=) or in an environment variable
>>
>>We have a winner. Thank you very much.
>
> and again, we may not - there is no standard. See
> http://www.pathname.com/fhs/
Furthermore, any process may set its own TZ value and all sub-processes
will run thus. So, peeking in any system file may yield wrong results.
Jonesy
--
Marvin L Jones | jonz | W3DHJ | linux
38.24N 104.55W | @ config.com | Jonesy | OS/2
* Killfiling google & XXXXbanter.com: jonz.net/ng.htm
|
|
0
|
|
|
|
Reply
|
bit-bucket (345)
|
10/25/2009 4:46:58 PM
|
|
On Sun, 25 Oct 2009 11:09:44 -0500, ibuprofin@painkiller.example.tld (Moe Trin) wrote:
>On Sun, 25 Oct 2009, in the Usenet newsgroup comp.os.linux.misc, in article
><slrnhe79ql.k8f.BitTwister@wcooker.home.test>, Bit Twister wrote:
>
>>Unruh wrote:
>
>>> Your particular distribution might have the information in say
>>> /etc/sysconfig/clock
>>> (ZONE=) or in an environment variable
>>
>>We have a winner. Thank you very much.
>
>and again, we may not - there is no standard. See
>http://www.pathname.com/fhs/
>
>The Linux Standard Base (http://www.linuxbase.org/spec/) does define
>a pair of C variables
>
> __timezone -- global variable containing timezone
>
> __tzname -- global variable containing the timezone
>
>
>but that's about it for standarization.
>
>>Proof:
>> . /etc/sysconfig/clock
>> echo $ZONE
>
>Doesn't work on non-RedHat derived systems, as already demonstrated by
>others.
I forget rest of this thread, what's wrong with:
~$ date "+%z %Z"
+1100 EST
~$ date -u "+%z %Z"
+0000 UTC
Grant.
--
http://bugsplatter.id.au
|
|
0
|
|
|
|
Reply
|
g_r_a_n_t_ (63)
|
10/25/2009 4:50:10 PM
|
|
Grant <g_r_a_n_t_@bugsplatter.id.au> writes:
>On Sun, 25 Oct 2009 11:09:44 -0500, ibuprofin@painkiller.example.tld (Moe Trin) wrote:
>>On Sun, 25 Oct 2009, in the Usenet newsgroup comp.os.linux.misc, in article
>><slrnhe79ql.k8f.BitTwister@wcooker.home.test>, Bit Twister wrote:
>>
>>>Unruh wrote:
>>
>>>> Your particular distribution might have the information in say
>>>> /etc/sysconfig/clock
>>>> (ZONE=) or in an environment variable
>>>
>>>We have a winner. Thank you very much.
>>
>>and again, we may not - there is no standard. See
>>http://www.pathname.com/fhs/
>>
>>The Linux Standard Base (http://www.linuxbase.org/spec/) does define
>>a pair of C variables
>>
>> __timezone -- global variable containing timezone
>>
>> __tzname -- global variable containing the timezone
>>
>>
>>but that's about it for standarization.
>>
>>>Proof:
>>> . /etc/sysconfig/clock
>>> echo $ZONE
>>
>>Doesn't work on non-RedHat derived systems, as already demonstrated by
>>others.
>I forget rest of this thread, what's wrong with:
>~$ date "+%z %Z"
>+1100 EST
>~$ date -u "+%z %Z"
>+0000 UTC
He said he wanted a name (America/Chicago). Whether that was actually true I do
not know.
|
|
0
|
|
|
|
Reply
|
unruh-spam (2581)
|
10/25/2009 5:18:12 PM
|
|
On Mon, 26 Oct 2009 03:50:10 +1100, Grant wrote:
> I forget rest of this thread, what's wrong with:
>
> ~$ date "+%z %Z"
> +1100 EST
Because I needed something like America/Chicago so I could
automagically modify /var/www/html/vtigercrm/config.inc.php,
to contain.
// Set the default timezone as per your preference
$default_timezone = 'America/Chicago';
Why, you ask, to clear this problem:
Warning: date() [function.date]: It is not safe to rely on the
system's timezone settings. You are *required* to use the
date.timezone setting or the date_default_timezone_set() function. In
case you used any of those methods and you are still getting this
warning, you most likely misspelled the timezone identifier. We
selected 'America/Chicago' for 'CDT/-5.0/DST' instead in
/var/www/html/vtigercrm/config.inc.php
|
|
0
|
|
|
|
Reply
|
BitTwister2 (1227)
|
10/25/2009 5:25:27 PM
|
|
On Sun, 25 Oct 2009 17:25:27 +0000 (UTC), Bit Twister <BitTwister@mouse-potato.com> wrote:
>On Mon, 26 Oct 2009 03:50:10 +1100, Grant wrote:
>
>> I forget rest of this thread, what's wrong with:
>>
>> ~$ date "+%z %Z"
>> +1100 EST
>
>Because I needed something like America/Chicago so I could
>automagically modify /var/www/html/vtigercrm/config.inc.php,
>to contain.
>
>// Set the default timezone as per your preference
>$default_timezone = 'America/Chicago';
>
>Why, you ask, to clear this problem:
>
>Warning: date() [function.date]: It is not safe to rely on the
>system's timezone settings. You are *required* to use the
>date.timezone setting or the date_default_timezone_set() function. In
>case you used any of those methods and you are still getting this
>warning, you most likely misspelled the timezone identifier. We
>selected 'America/Chicago' for 'CDT/-5.0/DST' instead in
>/var/www/html/vtigercrm/config.inc.php
Okay, I dug around in a fresh slack-13.0 install, the master zone
information lives in
/usr/share/zoneinfo/zone.tab
and your Chicago entry looks like:
US +415100-0873900 America/Chicago Central Time
Fields are iso country code, latitude and logitude, zone name, comment.
The file header gives details, you could read this file and calculate
the equivalent timezone offset --> zone name? Or lookup a zone name to
make sure it's in the list.
Grant.
--
http://bugsplatter.id.au
|
|
0
|
|
|
|
Reply
|
g_r_a_n_t_ (63)
|
10/25/2009 9:39:16 PM
|
|
On Mon, 26 Oct 2009, in the Usenet newsgroup comp.os.linux.misc, in article
<otg9e5hcf6vqhdjhigi748sk89cpqd05ir@4ax.com>, Grant wrote:
>Bit Twister <BitTwister@mouse-potato.com> wrote:
>> Grant wrote:
>>> I forget rest of this thread, what's wrong with:
>>>
>>> ~$ date "+%z %Z"
>>> +1100 EST
>>Because I needed something like America/Chicago so I could
>>automagically modify /var/www/html/vtigercrm/config.inc.php,
>>to contain.
>>
>>// Set the default timezone as per your preference
>>$default_timezone = 'America/Chicago';
>Okay, I dug around in a fresh slack-13.0 install, the master zone
>information lives in
>
> /usr/share/zoneinfo/zone.tab
>
>and your Chicago entry looks like:
>
> US +415100-0873900 America/Chicago Central Time
He needs the defined name, and doesn't have any other source. The
problem is shown as follows
[compton ~]$ grep America/Chicago time.2009o/Time.zone.names
America/Chicago USA US y -6:00 CST/CDT
[compton ~]$ grep -c USA time.2009o/Time.zone.names
37
[compton ~]$ awk '{ print $5 }' time.2009o/Time.zone.names | sort -n |
uniq -c | column
4 -11:00 26 -3:00 1 4:30 3 9:30
7 -10:00 1 -3:30 11 5:00 13 10:00
5 -9:00 2 -2:00 2 5:30 1 10:30
1 -9:30 3 -1:00 1 5:45 6 11:00
7 -8:00 28 0:00 10 6:00 1 11:30
14 -7:00 48 1:00 2 6:30 13 12:00
24 -6:00 38 2:00 10 7:00 1 12:45
32 -5:00 20 3:00 18 8:00 2 13:00
38 -4:00 1 3:30 1 8:45 1 14:00
1 -4:30 9 4:00 8 9:00
[compton ~]$ wc -l time.2009o/Time.zone.names
414 time.2009o/Time.zone.names
[compton ~]$
So there really isn't a substitute for having the real zone name. The
24 -06:00 zones are in eleven countries from Canada to Chile. At the
same time, there are 37 timezone _names_ in the US alone (and 13 in
Oz). The whole mess is just as standardized as the operating systems.
Old guy
|
|
0
|
|
|
|
Reply
|
ibuprofin2 (2555)
|
10/26/2009 12:13:50 AM
|
|
|
13 Replies
62 Views
(page loaded in 0.145 seconds)
|