Timezone conversion by command line

Solution 1:

It's 6pm in Taipei, what time is it here?

date --date='TZ="Asia/Taipei" 18:00'
Fri Jul 16 11:00:00 BST 2010

At 11am here in London, what time is it in Taipei?

TZ=Asia/Taipei date -d "11:00 BST"
Fri Jul 16 18:00:00 CST 2010

Solution 2:

I think this is closer to what the OP asked (Since he doesn't necessarily know that BST is Taipei? and the answer doesn't explain how to get to "Asia/Taipei" from 'BST').

First my current date:

$ date
Mon Apr 21 13:07:21 MDT 2014

Then the date I want to know:

$ date -d '5pm BST'
Mon Apr 21 15:00:00 MDT 2014

So I know that 5pm BST is 2 hours away.

I usually forget if I have to add or remove two hours from EDT times so I have a little script with the common timezones I have to work with:

$ cat tz
#!/bin/bash
TZ='America/Edmonton' date
TZ='America/Chicago' date
TZ='America/New_York' date

And the output:

$ tz
Mon Apr 21 13:12:32 MDT 2014
Mon Apr 21 14:12:32 CDT 2014
Mon Apr 21 15:12:32 EDT 2014

Valid locations for your tz script can be found here /usr/share/zoneinfo.

But again, for times in the future I just use date -d '<time> <timezone>'.

Solution 3:

This example is from http://www.pixelbeat.org/cmdline.html#dates

It gives the local time corresponding to 9AM on the west coast of the US, accounting for differing day light savings transitions.

date --date='TZ="America/Los_Angeles" 09:00 next Fri'

Use tzselect to get the TZ. The PST format is ambiguous. IST = Indian Standard Time and Irish Summer Time for example.