Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TZ=GMT+1 for date command is NOT working?

667 views
Skip to first unread message

Peter Ohoven

unread,
May 24, 2008, 5:08:04 AM5/24/08
to
Currently I am sitting here in the Timezone GMT+1 (Frankfurt/Germany).
I am logged in on a computer which is in Timezone PDT

When I enter now:

date

then the remote computer gives me:
Sat May 24 02:01:18 PDT 2008

When I enter then:

TZ=GMT+1 date

then the computer returns:

Sat May 24 08:01:36 GMT 2008

First error: The Timestamp return should from my view return "GMT+1" and not only "GMT".
Second error: The time is wrong. It should return either at least

Sat May 24 10:01:36 GMT 2008

or even better:

Sat May 24 11:01:36 GMT+1 2008

So even I subtract the possibly not considered daylight saving hour lag the time is wrong.

What's the error?

Peter

dillinger

unread,
May 24, 2008, 7:30:59 AM5/24/08
to

Check this page:

http://www.gnu.org/software/coreutils/manual/html_node/Specifying-time-zone-rules.html

TZ="Europe/Berlin" date
should give you the correct local time and timezone:
Sat May 24 13:28:02 CEST 2008

TZ=anything date returns:
Sat May 24 11:29:33 anything 2008
Which is the hardware time of the computer, normally UTC (GMT).

Michel.

Bill Marcum

unread,
May 24, 2008, 7:58:46 AM5/24/08
to
man 3 timezone (Debian or Ubuntu must have manpages-dev package installed):

The value of TZ can be one of three formats. The first format is used
when there is no daylight saving time in the local time zone:

std offset

The std string specifies the name of the time zone and must be three or
more alphabetic characters. The offset string immediately follows std
and specifies the time value to be added to the local time to get Coor‐
dinated Universal Time (UTC). The offset is positive if the local time
zone is west of the Prime Meridian and negative if it is east.

Joachim Schmitz

unread,
May 24, 2008, 9:11:06 AM5/24/08
to
3 errors actually
1st Frankfurt/Germany is GMT-1, not GMT+1 (yes, I don't understand the logic
either the clock shows 1 houre later than GMT, but that's the way it is).
2nd the TZ name is CET not GMT, TZ=CET-1
3rd Germany observers Summer/Daylight savinges time, so currently it is
TZ=CEST-2

The full TZ (which works thoughout the year, every year) is
TZ="CET-1CEST-2,M3.5.0,M10.5.0"

Bye, Jojo


Kees Theunissen

unread,
May 24, 2008, 1:37:57 PM5/24/08
to
Joachim Schmitz wrote:
> The full TZ (which works thoughout the year, every year) is
> TZ="CET-1CEST-2,M3.5.0,M10.5.0"

Don't be too sure about this "works [...] every year" claim. The
DST rules changed often in the past, and likely will change again
in the future. The last change for Germany was in 1996.
Processing of historical timestamps will fail with your fixed rule
in the TZ environment variable. Defining the right zoneinfo file in
the TZ variable will handle rule changes properly.

The partial dump of the Europe/Berlin zoneinfo file below shows
the last change for Germany.

~$ /usr/sbin/zdump -v /usr/share/zoneinfo/Europe/Berlin |grep -E '199(5|6)'
/usr/share/zoneinfo/Europe/Berlin Sun Mar 26 00:59:59 1995 UTC = Sun
Mar 26 01:59:59 1995 CET isdst=0 gmtoff=3600
/usr/share/zoneinfo/Europe/Berlin Sun Mar 26 01:00:00 1995 UTC = Sun
Mar 26 03:00:00 1995 CEST isdst=1 gmtoff=7200
/usr/share/zoneinfo/Europe/Berlin Sun Sep 24 00:59:59 1995 UTC = Sun
Sep 24 02:59:59 1995 CEST isdst=1 gmtoff=7200
/usr/share/zoneinfo/Europe/Berlin Sun Sep 24 01:00:00 1995 UTC = Sun
Sep 24 02:00:00 1995 CET isdst=0 gmtoff=3600
/usr/share/zoneinfo/Europe/Berlin Sun Mar 31 00:59:59 1996 UTC = Sun
Mar 31 01:59:59 1996 CET isdst=0 gmtoff=3600
/usr/share/zoneinfo/Europe/Berlin Sun Mar 31 01:00:00 1996 UTC = Sun
Mar 31 03:00:00 1996 CEST isdst=1 gmtoff=7200
/usr/share/zoneinfo/Europe/Berlin Sun Oct 27 00:59:59 1996 UTC = Sun
Oct 27 02:59:59 1996 CEST isdst=1 gmtoff=7200
/usr/share/zoneinfo/Europe/Berlin Sun Oct 27 01:00:00 1996 UTC = Sun
Oct 27 02:00:00 1996 CET isdst=0 gmtoff=3600


Regards,

Kees.

--
Kees Theunissen.

Joachim Schmitz

unread,
May 25, 2008, 7:29:56 AM5/25/08
to
Kees Theunissen wrote:
> Joachim Schmitz wrote:
>> The full TZ (which works thoughout the year, every year) is
>> TZ="CET-1CEST-2,M3.5.0,M10.5.0"
>
> Don't be too sure about this "works [...] every year" claim. The
> DST rules changed often in the past, and likely will change again
> in the future. The last change for Germany was in 1996.
> Processing of historical timestamps will fail with your fixed rule
> in the TZ environment variable. Defining the right zoneinfo file in
> the TZ variable will handle rule changes properly.
True, when I replied, I wasn't aware that it was about Linux (I read it in
comp.unix.shell, and I also missed the stupid 'Follow-Up-To') and not every
POSIX copliant OS does have zoneinfo. On those systems, however, the setting
I described is to be prefered over fixed days for the switching as that
would need to get calculated and changed once a year, while 'my' setting
only needs to get changed on the relavily rare occasions when the law
changes.

Bye, Jojo


Geoff Clare

unread,
May 27, 2008, 9:32:02 AM5/27/08
to
Bill Marcum wrote:

>> TZ=GMT+1 date

>> First error: The Timestamp return should from my view return "GMT+1"
>> and not only "GMT".
>> Second error: The time is wrong.

> man 3 timezone (Debian or Ubuntu must have manpages-dev package installed):


>
> The value of TZ can be one of three formats. The first format is used
> when there is no daylight saving time in the local time zone:
>
> std offset
>
> The std string specifies the name of the time zone and must be three or
> more alphabetic characters. The offset string immediately follows std

> and specifies the time value to be added to the local time to get Coor-


> dinated Universal Time (UTC). The offset is positive if the local time
> zone is west of the Prime Meridian and negative if it is east.

And if the OP really wants "GMT+1" as the timezone name, he could try:

TZ="<GMT+1>-1" date

This works on systems that conform to POSIX.1-2001 (tested on Solaris 10),
but it appears that Linux doesn't (yet?) support this use of '<' and '>'.

--
Geoff Clare <net...@gclare.org.uk>

Stephane CHAZELAS

unread,
May 27, 2008, 10:37:14 AM5/27/08
to
2008-05-27, 14:32(+01), Geoff Clare:
[...]

> And if the OP really wants "GMT+1" as the timezone name, he could try:
>
> TZ="<GMT+1>-1" date
>
> This works on systems that conform to POSIX.1-2001 (tested on Solaris 10),
> but it appears that Linux doesn't (yet?) support this use of '<' and '>'.

More precisely, it is not supported by the GNU libc but it is
supported by uclibc, so it depends which /Linux/ you're talking
of.

It doesn't seem to be supported by Solaris 8. Is it a recent
addition to the standard?

--
Stéphane

jpd

unread,
May 28, 2008, 1:11:38 AM5/28/08
to
Begin <4837daf4$0$7534$9b4e...@newsspool1.arcor-online.net>

On 24 May 2008 09:08:04 GMT, Peter Ohoven <p....@hotmail.com> wrote:
> Currently I am sitting here in the Timezone GMT+1 (Frankfurt/Germany).

If you're in Frankfurt, you'll be in CET/MEZ TZ, which is currently
actually CEST (CET+daylight savings) and as such GMT+2.

On my (FreeBSD) system, sh -c 'TZ=CET date' gives the expected result:

Wed May 28 07:05:34 CEST 2008

Whether using GMT+/-N notation does useful things I won't comment on,
but I will say that using ``unsupported'' values for TZ= can silently
cause interesting results.


--
j p d (at) d s b (dot) t u d e l f t (dot) n l .
This message was originally posted on Usenet in plain text.
Any other representation, additions, or changes do not have my
consent and may be a violation of international copyright law.

Joachim Schmitz

unread,
May 28, 2008, 3:51:04 AM5/28/08
to
jpd wrote:
> Begin <4837daf4$0$7534$9b4e...@newsspool1.arcor-online.net>
> On 24 May 2008 09:08:04 GMT, Peter Ohoven <p....@hotmail.com> wrote:
>> Currently I am sitting here in the Timezone GMT+1
>> (Frankfurt/Germany).
>
> If you're in Frankfurt, you'll be in CET/MEZ TZ, which is currently
> actually CEST (CET+daylight savings) and as such GMT+2.
GMT-2, not GMT+2, even if it is 2 hours later than GMT.
Or better:
CEST-2
Both setiing result in the correct time being displayed, but the earlier in
a wrong timezone to be shown.

the -2 is the offset to GMT/UTC, so it indicates by how many hours GMT/UTC
is off, which is indeed 2 hours for CEST

Bye, Jojo


Stephane Chazelas

unread,
May 28, 2008, 4:48:06 AM5/28/08
to
2008-05-28, 05:11(+00), jpd:

> Begin <4837daf4$0$7534$9b4e...@newsspool1.arcor-online.net>
> On 24 May 2008 09:08:04 GMT, Peter Ohoven <p....@hotmail.com> wrote:
>> Currently I am sitting here in the Timezone GMT+1 (Frankfurt/Germany).
>
> If you're in Frankfurt, you'll be in CET/MEZ TZ, which is currently
> actually CEST (CET+daylight savings) and as such GMT+2.
>
> On my (FreeBSD) system, sh -c 'TZ=CET date' gives the expected result:
>
> Wed May 28 07:05:34 CEST 2008
>
> Whether using GMT+/-N notation does useful things I won't comment on,
> but I will say that using ``unsupported'' values for TZ= can silently
> cause interesting results.
[...]

BTW, I don't know if it has be mentionned already, but the
GMT+xxx is obtained by date +GMT%z, not date +%Z

Note that in some locales on some systems the default date
output has the GMT offset rather than the timezone name.

~$ date
Wed May 28 09:43:15 BST 2008
~$ LC_TIME=fr_FR date
mercredi 28 mai 2008, 09:43:21 (UTC+0100)

~$ locale date_fmt
%a %b %e %H:%M:%S %Z %Y
~$ LC_TIME=fr_FR locale date_fmt
%A %-e %B %Y, %H:%M:%S (UTC%z)

(that's with GNU libc).

BST is British Summer time which is one hour east of GMT
defined as BST-1

Mnemonic: <TZ variable> == GMT
So BST == GMT + 1
gives BST - 1 == TZ

--
Stéphane

Geoff Clare

unread,
May 28, 2008, 8:58:16 AM5/28/08
to
Stephane CHAZELAS wrote:

It was added in the 2001 revision.

--
Geoff Clare <net...@gclare.org.uk>

0 new messages