How to know when time zone has changed and when timezone will change in linux
Answers
-
You can use
zdump
:NAME zdump - timezone dumper SYNOPSIS zdump [ --version ] [ --help ] [ -v ] [ -c [loyear,]hiyear ] [ zonename ... ] DESCRIPTION Zdump prints the current time in each zonename named on the command line.
Example:
zdump -v -c 2023,2025 "Europe/Berlin"
You may reffer https://man7.org/linux/man-pages/man8/zdump.8.html
And to be able to print even in better format, easier to use inside codes and getting the system time zone dynamically, you can use the command (feel free to update as per your requirement).
zdump -v -c 2023,2025 "$(timedatectl | grep 'Time zone' | awk -F ': ' '{print $2}' | awk -F ' ' '{print $1}')" | grep isdst | awk '{print $9","$10","$11","$12","$13","$14","$15}'
0 -
The above command will give the list of dates when timezone changes, you can also try another command in linux.
timedatectl status
This will output all the details you need on timezone
Local time: Wed 2023-11-22 04:26:14 EST Universal time: Wed 2023-11-22 09:26:14 UTC RTC time: Wed 2023-11-22 09:26:12 Time zone: America/New_York (EST, -0500) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: no Last DST change: DST ended at Sun 2023-11-05 01:59:59 EDT Sun 2023-11-05 01:00:00 EST Next DST change: DST begins (the clock jumps one hour forward) at Sun 2024-03-10 01:59:59 EST Sun 2024-03-10 03:00:00 EDT
1
Howdy, Stranger!
Categories
- 94 All Categories
- 20 VoIP
- 7 SIP
- 16 asterisk
- 44 Programming
- 1 Nodejs
- 4 javascript
- 19 PHP
- 8 Codeigniter
- 14 database
- 1 UI/UX
- 2 Flutter
- 28 OS
- 26 Linux
- 1 Virtualization
- 1 Android
- 1 Windows
- 2 legal