0

Last weekend most of Western Europe shifted back one hour - there were two instances of 2017-10-29T02:00.

To translate the time into UTC I can use GNU date:

$ date -d 'TZ="Europe/Rome" 2017-10-29 02:00'
Sun Oct 29 01:00:00 UTC 2017

This returns the time in CET (ie the second 2am). How do I get date to return Sun Oct 29 00:00:00 UTC 2017 (the first 2am - CEST)?

Info:

$ date --version
date (GNU coreutils) 8.21
  • Actually, CEST ended on October 29, at 3:00 AM. So, 2 AM CET was 3 AM CEST. – kiamlaluno Oct 30 '17 at 6:06
  • @kiamlaluno - I thought that’s what I said. At 3am the clocks went back an hour to 2am - ie two 2 AMs – DarkHeart Oct 30 '17 at 6:21
  • Did you try date -u ? – Serge Oct 30 '17 at 7:03
  • You are saying you get Sun Oct 29 01:00:00 UTC 2017 as output of date -d 'TZ="Europe/Rome" 2017-10-29 02:00' and you would want to get Sun Oct 29 00:00:00 UTC 2017, which is two hours earlier than the input. That is not just changing from CEST to CET or vice versa. On October 29, 2017, 2:00 AM CEST is 2:00 AM CEST, and 2:00 AM CET is 3:00 AM CEST. – kiamlaluno Oct 30 '17 at 9:13
  • @kiamlaluno - Yes I want to change UTC to Europe time - having date translate both hours (2am CEST and 2am CET) not just the one. – DarkHeart Oct 31 '17 at 0:20
1

The reference for timezone changes is zdump:

$ /usr/sbin/zdump -v -c 2017,2018 Europe/Rome
Europe/Rome  -9223372036854775808 = NULL
Europe/Rome  -9223372036854689408 = NULL
Europe/Rome  Sun Mar 26 00:59:59 2017 UTC = Sun Mar 26 01:59:59 2017 CET isdst=0
Europe/Rome  Sun Mar 26 01:00:00 2017 UTC = Sun Mar 26 03:00:00 2017 CEST isdst=1
Europe/Rome  Sun Oct 29 00:59:59 2017 UTC = Sun Oct 29 02:59:59 2017 CEST isdst=1
Europe/Rome  Sun Oct 29 01:00:00 2017 UTC = Sun Oct 29 02:00:00 2017 CET isdst=0
Europe/Rome  9223372036854689407 = NULL
Europe/Rome  9223372036854775807 = NULL
|improve this answer|||||
1

The time TZ="Europe/Rome" 2017-10-29 02:00 is ambiguous since this translates to two different UTC times, 00:00 and 01:00.

How to make date return both is to specify the exact timezone itself, eg

$ date -ud 'TZ="Europe/Rome" 02:00:00 10/29/2017 CEST'
Sun Oct 29 00:00:00 UTC 2017
$ date -ud 'TZ="Europe/Rome" 02:00:00 10/29/2017 CET'
Sun Oct 29 01:00:00 UTC 2017

However this means you have to work out the timezone outside the date command.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.