Productivity Hack : Bash Shell Script to Show Current Time in Different Timezones

I regularly work with my colleagues and customers based out in multiple time zones. Referencing time converter websites or doing mental maths gymnastics to convert time is not my thing, so I ended up creating a simple shell script for my commonly used timezone. You can add your own timezones and add an alias to call it from terminal to make it easier.

Script tested on Linux and Mac. It takes local times and outputs in different timezones of your choice

#!/bin/bash
echo "----------------------------"
echo "Local Time"
date
echo "----------------------------"
echo ""
echo "Time in Los Angeles"
export TZ=America/Los_Angeles
date
echo ""
echo "Time in San Francisco"
export TZ=US/Pacific
date
echo ""
echo "Time in Dallas,TX"
export TZ=US/Central
date
echo ""
echo "Time in New York"
export TZ=America/New_York
date
echo ""
echo "^"
echo "|"
echo "|"
echo "----------------------------"
echo "Time in UTC"
export TZ=UTC
date
echo "----------------------------"
echo "|"
echo "|"
echo "v"
echo ""
echo "Time in India-Mumbai"
export TZ=Asia/Calcutta
date
echo ""
echo "Time in Singapore"
export TZ=Asia/Singapore
date
echo ""
echo "Time in Perth"
export TZ=Australia/Perth
date
echo ""
echo "Time in Adelaide"
export TZ=Australia/Adelaide
date
echo ""
echo "Time in Sydney"
export TZ=Australia/Sydney
date
echo ""
echo "Time in Auckland"
export TZ=Pacific/Auckland
date
echo ""
unset TZ

Add an alias and call from command line

$ alias japactime='"/Users/shadab/Downloads/TIME.sh"'
$ japactime

Category: DatabaseLinuxShell Scripts

Tags:

Leave a Reply

Article by: Shadab Mohammad