Linux machines use UTC clock so does bash script, If your script needs time from a different timezone then you have to convert current UTC to let's say PDT, how do we do it in bash.
Python has widely used programing language and has lots of libraries for this, But funny this is bash very answer for this, just export TZ variable. As simple as this.
Let's try this snippet on a Linux machine. It prints time from 3 timezones PDT, UTC, and IST.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gil@localhost:/home/gil# TZ=America/Los_Angeles date ;date ; TZ=Asia/Kolkata date | |
Wed Jul 22 13:42:56 PDT 2020 | |
Wed Jul 22 20:42:56 UTC 2020 | |
Thu Jul 23 02:12:56 IST 2020 |
0 Comments