Re: sh-utils 2.0: date fails to convert seconds since epoch to date
Jim Meyering <[email protected]> Sun, 25 Aug 2002 22:30:46 +0200
| Newsgroups | gmane.comp.gnu.sh-utils.bugs |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> 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"