On Wed, Nov 24, 2004 at 05:57:50PM +1100, Michael Knight wrote:
> Does this work as expected? When I run it I get:
>
> $ date --date '1081207440 seconds'
> date: invalid date `1081207440 seconds'
>
> and
>
> $ date --date '100000 seconds'
> Thu Nov 25 21:42:30 EST 2004
>
> It seems the seconds provided act as an offset to the current time,
> unless I'm missing something or my `date' is broken.
My bad; yes it is an offset. So you would need to tell it to add
it to the 'beginning of unix time' which is 1/1/1970 GMT, which is
10:00am 1/1/1970 Sydney time:
$ date
Thu Nov 25 13:00:08 EST 2004
$ date +%s
1101348011
$ date --date '1/1/1970 10:00am + 1101348011 seconds'
Thu Nov 25 13:00:11 EST 2004
The syntax --date thing is fun -- you can use words like 'yesterday'
and 'now' but fairly underspecified and you can get surprised :
e.g. adding 2 assumes hours and adds to the _beginning_ of the date
but adding 2 seconds adds to the _current_ time.
$ date --date 'now + 2'
Thu Nov 25 02:00:00 EST 2004
$ date --date 'now + 2 seconds'
Thu Nov 25 13:03:48 EST 2004
Hmmmm.
--
Matt
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html