bug-coreutils
[Top][All Lists]
Advanced

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

Re: date +%s ignores TZ


From: Bob Proulx
Subject: Re: date +%s ignores TZ
Date: Fri, 29 Feb 2008 14:20:17 -0700
User-agent: Mutt/1.5.13 (2006-08-11)

Jan Engelhardt wrote:
>       $ date +%s
>       1204311113

    %s  seconds since 1970-01-01 00:00:00 UTC

>       $ TZ=GMT date +%s
>       1204311113
>       $ TZ=PDT date +%s
>       1204311113

Right.  I assume you were *very fast* typing in that data and that
seconds did not move on while you were doing it.  :-)  I get the point
though.  That value is a timezone independent value.

> but is there actually a way to do
> 
>       $ TZ=anything date +%s -d "`date '+%Y-%m-%d %H:%M:%S'`";
> 
> without invoking date twice?

I think something was lost in translation.

  date '+%Y-%m-%d %H:%M:%S'

That will always produce the current time.  That means that

  date +%s -d "`date '+%Y-%m-%d %H:%M:%S'`"

is always the same as

  date +%s

There is no need to call date twice to get that result.

Please say a few more words about what you are trying to do.  I think
with a little more understanding it will make better sense.  I see
that you are trying to produce a unix seconds epoch based upon some
time but creating it with date doesn't do it.  You would need some
other time.

  date +%s -d 'last thursday'
  1204182000

Bob




reply via email to

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