bug-coreutils
[Top][All Lists]
Advanced

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

Re: date +%s ignores TZ


From: Jan Engelhardt
Subject: Re: date +%s ignores TZ
Date: Fri, 29 Feb 2008 22:51:11 +0100 (CET)

On Feb 29 2008 14:20, Bob Proulx wrote:
>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.

There is (my default zone is /etc/localtime ->
/usr/share/zoneinfo/Europe/Berlin):

        $ TZ=GMT date +%s -d "`date '+%Y-%m-%d %H:%M:%S'`"
        1204325194
        $ date +%s
        1204321595

        (now with not-so-fast typing! :)

>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 wanted to get the number of seconds since the start of the day.

        echo $[`date +%s` % 86400];

unfortunately does not do the right thing — it would show
82800 instead of 0 when it is (local) midnight.




reply via email to

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