bug-sh-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sh-utils 2.0: date fails to convert seconds since epoch to date


From: Per Cederqvist
Subject: sh-utils 2.0: date fails to convert seconds since epoch to date
Date: 16 Aug 2002 15:42:18 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

Using "date +%s" I can get the number of seconds since the epoch.
Fine.  I now want to convert it back to a date.  The manual states
that I can do so:

>      To convert such an unwieldy number of seconds back to a more
>      readable form, use a command like this:
> 
>           date -d '1970-01-01 946684800 sec' +"%Y-%m-%d %T %z"
>           2000-01-01 00:00:00 +0000

Reading this, I would expect that

        date; date -d "1970-01-01 `date +%s` sec"

would produce two equal lines (unless I run the commands just as the
clock ticks).  However, there is a 1-hour difference:

Fri Aug 16 15:34:52 MEST 2002
Fri Aug 16 14:34:52 MEST 2002

If I set TZ=GMT and re-run the commands, I get the expected result:

Fri Aug 16 13:35:28 GMT 2002
Fri Aug 16 13:35:28 GMT 2002

TZ was unset when I ran the first commands.

I have tested this under Linux 2.4.18pre1 using glibc-2.2.5, and under
Solaris 2.8.

Daylight savings time is currently in effect.  I'm 1 hour from UTC.

        /ceder




reply via email to

[Prev in Thread] Current Thread [Next in Thread]