Tuesday, January 25, 2011

Telling time in different timezones with bash on OSX

You can use the TZ variable to affect the execution of date command.

Current time in Japan Standard Time (JST)
TZ=Asia/Tokyo date

Pacific Standard Time (PST)
TZ=America/Los_Angeles date

Eastern Standard Time (EST)
TZ=America/New_York date

Central Standard Time (CST)
TZ=America/Chicago date

Coordinated Universal Time (UTC) / Greenwich Mean Time (GMT)
TZ=Europe/London date

Central European Time (CET)
TZ=Europe/Budapest date

Here is how i use it. telltime.sh


  1. that is very handy. I need to do that all the time.
    and by the way in your bash script
    you can use for i in a b c d
    to cycle through the timezones

    that would make your script much shorter.

  2. i just updated the code, have a look.
    you could organize the code into a function which makes the code more compact.

  3. Is there anyway to adjust for Daylight savings time? Your London time is off because of their local day light savings time.

  4. @Brent, 'TZ=Europe/London date' shows the adjusted time on snow leopard, which is UTC/GMT +1 hour