Reputation: 864
Here is an example:
root@linux:~# timedatectl
Local time: Thu 2016-03-31 08:33:23 CEST
Universal time: Thu 2016-03-31 06:33:23 UTC
RTC time: n/a
Time zone: Africa/Ceuta (CEST, +0200)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
Sun 2016-03-27 01:59:59 CET
Sun 2016-03-27 03:00:00 CEST
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2016-10-30 02:59:59 CEST
Sun 2016-10-30 02:00:00 CET
root@linux:~# echo $string
1970 01 01 0 0 0
root@linux:~# awk -v str="$string" 'BEGIN {print mktime(str)}'
0
root@linux:~# timedatectl set-timezone Europe/Berlin
root@linux:~# timedatectl
Local time: Thu 2016-03-31 08:59:01 CEST
Universal time: Thu 2016-03-31 06:59:01 UTC
RTC time: n/a
Time zone: Europe/Berlin (CEST, +0200)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: yes
Last DST change: DST began at
Sun 2016-03-27 01:59:59 CET
Sun 2016-03-27 03:00:00 CEST
Next DST change: DST ends (the clock jumps one hour backwards) at
Sun 2016-10-30 02:59:59 CEST
Sun 2016-10-30 02:00:00 CET
root@linux:~# echo $string
1970 01 01 0 0 0
root@linux:~# awk -v str="$string" 'BEGIN {print mktime(str)}'
-3600
2 question: And why mktime output (when input 1970-01-01T00:00:00 ) for Europe/Berlin timezone is -1 hour?
Upvotes: 1
Views: 301
Reputation: 219548
timedatectl
(apparently) shows the current timezone rules in effect for the currently set timezone. However timezone rules change over time within the same timezone.
As of today, both Africa/Ceuta and Europe/Berlin have the same UTC offset, and follow the exact same rules for daylight savings. But they haven't always done so.
In 1970-01-01 Africa/Ceuta used a 0:00:00 UTC offset and did not use daylight saving.
In 1970-01-01 Europe/Berlin used a 1:00:00 UTC offset and did not use daylight saving.
It wasn't until 1986-03-30 01:00:00 UTC that Africa/Ceuta and Europe/Berlin adopted the same rules. Your computer knows this history, and accurately reflects it when doing conversions between UTC and local time for dates prior to 1986-03-30.
Upvotes: 1
Reputation: 125
they change to Summer and Winter-times at different dates, which is why the times might be different even though they have the same UTC offset
Upvotes: 0