bug-coreutils
[Top][All Lists]
Advanced

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

Re: date +%s ignores TZ


From: Philip Rowlands
Subject: Re: date +%s ignores TZ
Date: Sat, 1 Mar 2008 18:48:48 +0000 (GMT)

On Fri, 29 Feb 2008, Bob Proulx wrote:

Jan Engelhardt wrote:

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.

I can't think of any totally race free way to do this without invoking
date multiple times.

I might be misunderstanding the problem, but it seems easy enough to do this calling date only once:

$ date +%T | awk -F: '{ print $1 * 3600 + $2 * 60 + $3 }'
67652

(corresponding to 18:47:32)


Cheers,
Phil






reply via email to

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