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

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

Re: shellutils; No way to input a date in time_t format


From: Bob Proulx
Subject: Re: shellutils; No way to input a date in time_t format
Date: Fri, 2 Mar 2001 22:47:48 -0700

> As a programmer, I often encounter dates in the time_t format
> (e.g. 983370715), and I'd like the 'date' command to understand them
> and to display them in a more readable way.  Unfortunately, GNU date
> seems to provide no way (no documented way, at least) to use that
> format as input.
> 
> Someone suggested a trick to me, but I guess you'll agree it's ugly:
> $ date -d 'Jan 1 1970 00:00:983370715 GMT'
> 
> So, I hereby express a wish for a new input format for 'date'.

Here is another trick for you.  I think I find the perl one easier to
type.

  date -d 'Jan 1 1970 00:00:983370715 GMT'
  Wed Feb 28 07:31:55 MST 2001

  perl -le 'print $v=localtime(983370715);'
  Wed Feb 28 07:31:55 2001

  perl -le 'print $v=gmtime(983370715);'
  Wed Feb 28 14:31:55 2001

The format of ctime(3) is unfortunate in not including the timezone.
If you are using gmtime then you can just include UTC.  Or if you know
your timezone you can include it in the print.  In any case this
provides another possibility.

Bob



reply via email to

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