bug-coreutils
[Top][All Lists]
Advanced

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

Re: a comment on the date command


From: Jim Meyering
Subject: Re: a comment on the date command
Date: Mon, 02 Feb 2004 17:02:56 +0100

"Nelson H. F. Beebe" <address@hidden> wrote:
> Also, it would be helpful if GNU date (also part of coreutils) could
> input and output time values since the epoch given on the command
> line, since that would make time conversions easy.  I know there is a
> perl module to do that, and GNU gawk can do it like this:
>
>       % gawk 'BEGIN{print strftime("%c", 941742458)}'
>       Thu Nov  4 12:07:38 1999
>
> Still, date is the obvious tool to provide such conversions.  As far
> as I can tell, GNU date provides one of the needed conversions:
>
>       % date '+%s'
>       1075736647
>
> but not the other
>
>       % date -d 1075736647
>       date: invalid date `1075736647'

Here's an example in `info date example'

     To convert such an unwieldy number of seconds back to a more
     readable form, use a command like this:

          # local time zone used
          date -d '1970-01-01 UTC 946684800 seconds' +"%Y-%m-%d %T %z"
          1999-12-31 19:00:00 -0500

     Often it is better to output UTC-relative date and time:

          date -u -d '1970-01-01 946684800 seconds' +"%Y-%m-%d %T %z"
          2000-01-01 00:00:00 +0000




reply via email to

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