Re: date bug

[email protected] (Bob Proulx) Tue, 7 Oct 2003 10:42:31 -0600
Newsgroups gmane.comp.gnu.sh-utils.bugs
Message-ID <[email protected]>
Dr. Roger J. McNichols wrote:
> BUG in date command.
> Using:
> date (GNU sh-utils) 1.16

Oh my.  That is a very old version.  Not that it will change anything
with your particular comment but you should consider updating to a
newer version of the utilities.

STABLE
  ftp://ftp.gnu.org/gnu/coreutils/coreutils-5.0.tar.gz
  ftp://ftp.gnu.org/gnu/coreutils/coreutils-5.0.tar.bz2
  (coreutils is the union of fileutils, textutils, and sh-utils)

BETA
  ftp://alpha.gnu.org/gnu/coreutils/coreutils-5.0.91.tar.gz
  ftp://alpha.gnu.org/gnu/coreutils/coreutils-5.0.91.tar.bz2

> Problem:
> There is no option to explicitly tell date the format of the 
> string supplied in the -d option.

True.  It is expecting a "News" style human readable format.

> Example:
> %  date -d `date +%s`
> date: invalid date `1065042571'

Try this instead.

  date -d "`date`"

If you are really trying to convert seconds to a date that can be
parsed by date then the example from the info page works.

     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

Bob