How to get date and time using date command from another timezone in Linux?

Posted on In QA, Tutorial

date command on Linux gets the date and time in the system timezone. But how to get date and time using date command from another timezone in Linux?

You can make date print the time of another timezone by setting the TZ environment variable.

For example,

export TZ=Hongkong; date
Sat Dec  1 09:39:13 HKT 2018

From the manual of date https://www.systutorials.com/docs/linux/man/1-date/

ENVIRONMENT

TZ
Specifies the timezone, unless overridden by command line parameters. If neither is specified, the setting from /etc/localtime is used.

Leave a Reply

Your email address will not be published. Required fields are marked *