Use Linux Date Command As A Timezone Converter

Date command is not only use for setting and viewing the date and time of system but it can also be used to display current date and time running in some other country or can also display future date and time of other country.

For this we must need the time zone information of the country.
In my system timezone files information is at /usr/share/zoneinfo/

Install tzdata package

First install the tzdata package which will be used for time zone information.

Note: For latest updated timezone information with system ,tzdata package should be installed

Install tzdata package in Red Hat Based Operating System

# In CentOS/Red Hat/Rocky Linux
yum install tzdata

Install tzdata package in Debian Based Operating System

# In Ubuntu/Debian based Operating System
sudo apt update
sudo apt -y install tzdata

Converting Time Zone By Date Command(Examples)

In this section, we will show some date command examples which will convert to our asking TimeZone.

Example 1

For eg. my system is running in IST (Indian Standard Time) and I would like to see right now what is the date and time running in Newzealand.

I will use the command TZ='Pacific/Auckland' date

See the below given eg. which shows what is current date time running in NewZealand.

root@tuxworld:~# date
Tue Jul  2 21:05:21 IST 2013

root@tuxworld:~# TZ='Pacific/Auckland' date
Wed Jul  3 03:35:34 NZST 2013
root@tuxworld:~# 

Example 2

root@tuxworld:~# date 
Tue Jul  2 21:14:07 IST 2013
root@tuxworld:~# 
root@tuxworld:~# TZ='America/Los_Angeles' date
Tue Jul  2 08:44:10 PDT 2013
root@tuxworld:~# 
root@tuxworld:~#

Example 3

What will be date and time in my country as per America/Los_Angeles timezone next friday at 9:00 AM ?

root@tuxworld:~# date --date='TZ="America/Los_Angeles" 09:00 next Fri'
Fri Jul  5 21:30:00 IST 2013

root@tuxworld:~# date --date='TZ="America/Los_Angeles" 13:00 4-Jul-2013'
Fri Jul  5 01:30:00 IST 2013
root@tuxworld:~#

Example 4

What will be date and time in my country as per America/Los_Angeles timezone 1:00 PM 4-July-2013 ?

root@tuxworld:~# date --date='TZ="America/Los_Angeles" 13:00 next Tuesday'
Wed Jul 10 01:30:00 IST 2013
root@tuxworld:~# 
root@tuxworld:~# date --date='TZ="Pacific/Auckland" 13:00 next Tuesday'
Tue Jul  9 06:30:00 IST 2013
root@tuxworld:~# 

In this article we have written Learn Date Command With Examples. This guide has so many Date command examples which will be really helpful.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.