This tutorial will help you to find time of different time zones on Linux command prompt or shell scripts. For example, your system is running with UTC timezone. When you execute “date” command on terminal, it will show you the current time of the timezone configured on your system. How do you find the time in other timezone without changing timezone of your system (eg: current EST time)
View Current EST Time
- Search on Google – Just open google.com and enter “current est time” in search bar. This will show you the current time in EST timezone.Advertisement
- View current est time on linux command line – You can also view the current time of any timezone, no matter what timezone is configured on your system. No need to change timezone of your system to view current time in other timezone like current est time.
TZ="EST" date
Output> Sunday 06 December 2020 06:12:59 AM ESTSimilarly, you can search for current time in other timzones, like:
TZ="UTC" date
# Current time in UTC TZ="GMT" date
# Current time in GMT TZ="PST" date
# Current time in PDT (Pasific Time) TZ="America/New_York" date
# Current time in America/New_York TZ="America/Virgin" date
# Current time in America/Virgin TZ="Europe/London" date
# Current time in Europe/London TZ="Europe/Paris" date
# Current time in Europe/Paris TZ="Australia/Sydney" date
# Current time in Australia/Sydney Use Current EST Time in Shell Scripts
Getting time of different time zones is useful while writing scripts. For example, you need to check current time in some other timezone that current system.
Just in case, your system is running in UTC timezone and your script required the current EST time. The below script will help you to find current EST time and store it in a variable. Which you can further use in your script.
1234567#!/bin/bash# Store current EST time in a variableEST_TIME=$(TZ="EST" date)# Print value stored in variableecho "Current time - $EST_TIME"Conclusion
Hope this tutorial helped you to find current time in different-2 time zones on Linux command line.