bug-coreutils
[Top][All Lists]
Advanced

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

bug#20850: Converting under Linux a by date calculated epochtime back wi


From: Pádraig Brady
Subject: bug#20850: Converting under Linux a by date calculated epochtime back with date, does not return the same data
Date: Fri, 19 Jun 2015 18:17:39 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

tag 20850 notabug
close 20850
stop

On 19/06/15 10:03, Bahn, Ingo wrote:
> Good Morning,
> 
> I am converting a timestamp into the respective epochtime number using the 
> 'date' command from 'coreutils'.
> When I convert this back however, the result differs from the initial input. 
> I'd expect the same, and which is the case actually under CygWin under WIN7.

tl;dr timezones

Your timestamp is ambiguous as it uses the current timezone.
You can fix it to UTC like:

 $ date -d "2015-06-18T06:27:01-0" +%s
 1434608821
 $ date -u -d "2015-06-18T06:27:01" +%s
 1434608821
 $ TZ=UTC date -d "2015-06-18T06:27:01" +%s
 1434608821

Converting back is not ambiguous,
though again will vary according to the timezone.
You can output in UTC for correlation like:

 $ date -u -d @1434608821
 Thu Jun 18 06:27:01 UTC 2015
 $ TZ=UTC date -d @1434608821
 Thu Jun 18 06:27:01 UTC 2015

thanks,
Pádraig.





reply via email to

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