[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sh-utils 2.0: date fails to convert seconds since epoch to date
From: |
Jim Meyering |
Subject: |
Re: sh-utils 2.0: date fails to convert seconds since epoch to date |
Date: |
Sun, 25 Aug 2002 22:30:46 +0200 |
User-agent: |
Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.3.50 (i686-pc-linux-gnu) |
Thanks for the report.
The documentation in the latest test release is better:
ftp://alpha.gnu.org/gnu/fetish/sh-utils-2.0.15.tar.gz
Per Cederqvist <address@hidden> wrote:
> 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
Add `UTC', as in this example, and it should work the way you expect:
date; date -d "1970-01-01 UTC `date +%s` sec"