With team members working from around the globe, it’s often crucial to be aware of the timezones for various locations. Generally, there are situations when you might want to quickly check the timezone for a given place. Fortunately, there’s a command-line utility named zdump that allows you to do just that.
This guide will cover the basics of how to use zdump with easy-to-follow examples. Please note that all examples in this tutorial have been tested on an Ubuntu 18.04 LTS system.
Linux zdump Command
The zdump command in Linux is primarily designed to dump timezone information. Below is its syntax:
zdump [--version] [--help] [-v] [-c [loyear,]hiyear] [zonename...]
According to the man page:
The zdump program prints the current time in each zonename named on the command line.
Here are some examples to give you a clear understanding of how the zdump command operates.
Q1. How to Use zdump Command?
Basic usage is quite straightforward. You simply execute ‘zdump’ followed by the location name. For instance:
zdump Singapore
This is the output generated on my system:
Singapore Wed Oct 31 17:35:39 2018 +08
Here are some more examples for clarity:
You can even use zdump to retrieve city-specific information. Here are a few examples:
Q2. How to Make zdump Produce Detailed Information in Output?
If you wish for zdump to generate detailed information, use the -v command line option. For example, the command:
zdump -v Singapore
produces the following output:
Singapore -9223372036854775808 = NULL Singapore -9223372036854689408 = NULL Singapore Mon Dec 31 17:04:34 1900 UT = Mon Dec 31 23:59:59 1900 LMT isdst=0 gmtoff=24925 Singapore Mon Dec 31 17:04:35 1900 UT = Tue Jan 1 00:00:00 1901 SMT isdst=0 gmtoff=24925 Singapore Wed May 31 17:04:34 1905 UT = Wed May 31 23:59:59 1905 SMT isdst=0 gmtoff=24925 Singapore Wed May 31 17:04:35 1905 UT = Thu Jun 1 00:04:35 1905 +07 isdst=0 gmtoff=25200 Singapore Sat Dec 31 16:59:59 1932 UT = Sat Dec 31 23:59:59 1932 +07 isdst=0 gmtoff=25200 Singapore Sat Dec 31 17:00:00 1932 UT = Sun Jan 1 00:20:00 1933 +0720 isdst=1 gmtoff=26400 Singapore Tue Dec 31 16:39:59 1935 UT = Tue Dec 31 23:59:59 1935 +0720 isdst=1 gmtoff=26400 Singapore Tue Dec 31 16:40:00 1935 UT = Wed Jan 1 00:00:00 1936 +0720 isdst=0 gmtoff=26400 Singapore Sun Aug 31 16:39:59 1941 UT = Sun Aug 31 23:59:59 1941 +0720 isdst=0 gmtoff=26400 Singapore Sun Aug 31 16:40:00 1941 UT = Mon Sep 1 00:10:00 1941 +0730 isdst=0 gmtoff=27000 Singapore Sun Feb 15 16:29:59 1942 UT = Sun Feb 15 23:59:59 1942 +0730 isdst=0 gmtoff=27000 Singapore Sun Feb 15 16:30:00 1942 UT = Mon Feb 16 01:30:00 1942 +09 isdst=0 gmtoff=32400 Singapore Tue Sep 11 14:59:59 1945 UT = Tue Sep 11 23:59:59 1945 +09 isdst=0 gmtoff=32400 Singapore Tue Sep 11 15:00:00 1945 UT = Tue Sep 11 22:30:00 1945 +0730 isdst=0 gmtoff=27000 Singapore Thu Dec 31 16:29:59 1981 UT = Thu Dec 31 23:59:59 1981 +0730 isdst=0 gmtoff=27000 Singapore Thu Dec 31 16:30:00 1981 UT = Fri Jan 1 00:30:00 1982 +08 isdst=0 gmtoff=28800 Singapore 9223372036854689407 = NULL Singapore 9223372036854775807 = NULL
According to the man page, this option is described as:
-v For each zonename on the command line, print the time at the lowest possible time value, the time one day after the lowest possible time value, the times both one second before and exactly at each detected time discontinuity, the time at one day less than the highest possible time value, and the time at the highest possible time value. Each line ends with isdst=1 if the given time is Daylight Saving Time or isdst=0 otherwise.
Q3. What Does the -c Option Do?
The -c option trims the verbose output starting near the provided year(s). The man page explains it as:
-c [loyear,]hiyear
Cut off the verbose output near the start of the given year(s). The output still includes the
lowest possible time value and one day after it, and the highest possible time value preceded
by the time value one day before it.
Here’s an example:
zdump -v -c 1935 Singapore
This command produces the output:
Singapore -9223372036854775808 = NULL Singapore -9223372036854689408 = NULL Singapore Mon Dec 31 17:04:34 1900 UT = Mon Dec 31 23:59:59 1900 LMT isdst=0 gmtoff=24925 Singapore Mon Dec 31 17:04:35 1900 UT = Tue Jan 1 00:00:00 1901 SMT isdst=0 gmtoff=24925 Singapore Wed May 31 17:04:34 1905 UT = Wed May 31 23:59:59 1905 SMT isdst=0 gmtoff=24925 Singapore Wed May 31 17:04:35 1905 UT = Thu Jun 1 00:04:35 1905 +07 isdst=0 gmtoff=25200 Singapore Sat Dec 31 16:59:59 1932 UT = Sat Dec 31 23:59:59 1932 +07 isdst=0 gmtoff=25200 Singapore Sat Dec 31 17:00:00 1932 UT = Sun Jan 1 00:20:00 1933 +0720 isdst=1 gmtoff=26400 Singapore 9223372036854689407 = NULL Singapore 9223372036854775807 = NULL
Conclusion
Although the zdump command might not be a tool that you’ll use daily, it’s an essential utility to be aware of. It’s handy, and you never know when it might come in useful. For more, you can refer to its man page.
FAQ
What is zdump used for?
zdump is a command-line utility used to display the current time in specified timezones or locations, providing a straightforward way to see timezone information quickly.
Which systems support zdump?
zdump is typically available on Unix-like operating systems, including various Linux distributions such as Ubuntu.
How can I access detailed documentation on zdump?
For detailed documentation, you can refer to the zdump man page by typing man zdump
in your terminal or visiting online resources like this link.
Does zdump handle daylight saving time?
Yes, zdump provides information about whether the given time falls during daylight saving time through the isdst
field in its output.