20
8
I know about http://www.timeanddate.com/worldclock/converter.html
I can't figure out how to query http://www.google.com in a sane natural format like "5pm BST in PST".
Or do I have to write such an app?
20
8
I know about http://www.timeanddate.com/worldclock/converter.html
I can't figure out how to query http://www.google.com in a sane natural format like "5pm BST in PST".
Or do I have to write such an app?
38
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
Strange, but the first way doesn't work for me: TZ=Europe/Moscow date --date='TZ="Asia/Taipei" 18:00'
Mon Mar 27 18:00:00 CST 2017
-- i.e. it just tells me the date in Taipei, not my local date for that time point. Although manpage says your method is correct. Am I missing something?.. coreutils 8.26
, Arch Linux – MarSoft – 2017-03-27T01:45:52.333
To find a timezone identifier use somethin like: timedatectl list-timezones|grep -i taipei
(prints Asia/Taipei
), timedatectl list-timezones|grep -i berlin
(prints Europe/Berlin
), timedatectl list-timezones|grep -i angeles
(prints America/Los_Angeles
) – exebook – 2019-05-24T05:45:17.213
6
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.
3Didn't know about tzselect
, thanks. If you enter wrong 'TZ' input you can get misleading results, e.g.
TZ=London date
Fri Jul 16 10:28:52 London 2010
– hendry – 2010-07-16T10:29:29.983
6
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>'
.
2
Use Wolfram Alpha. To the basic URL…
http://www.wolframalpha.com/input/?i=
append the conversion, with spaces replaced by +
. For example:
http://www.wolframalpha.com/input/?i=5+PM+CET+to+PST
Note that Wolfram Alpha does not seem to recognize BST
as a time zone.
how does one quickly look up time zone codes? – hendry – 2010-07-16T10:31:08.123
@hendry This is a cool interactive online map: http://www.timeanddate.com/time/map/#%21cities=241
– DavidG – 2014-04-21T19:48:45.1231
I know it is an old thread, but I needed a code for the same use case and, based on the ideas here, developed this little bash script:
#!/bin/bash
# ig20180122 - displays meeting options in other time zones
# set the following variable to the start and end of your working day
myday="8 20" # start and end time, with one space
# set the local TZ
myplace='America/Sao_Paulo'
# set the most common places
place[1]='America/Toronto'
place[2]='America/Chicago' # Houston as well
place[3]='Europe/Amsterdam'
place[4]='Europe/Dublin'
# add cities using place[5], etc.
# set the date format for search
dfmt="%m-%d" # date format for meeting date
hfmt="+%B %e, %Y" # date format for the header
# no need to change onwards
format1="%-10s " # Increase if your cities are large
format2="%02d "
mdate=$1
if [[ "$1" == "" ]]; then mdate=`date "+$dfmt"`; fi
date -j -f "$dfmt" "$hfmt" "$mdate"
here=`TZ=$myplace date -j -f "$dfmt" +%z "$mdate"`
here=$((`printf "%g" $here` / 100))
printf "$format1" "Here"
printf "$format2" `seq $myday`
printf "\n"
for i in `seq 1 "${#place[*]}"`
do
there=`TZ=${place[$i]} date -j -f "$dfmt" +%z "$mdate"`
there=$((`printf "%g" $there` / 100))
city[$i]=${place[$i]/*\//}
tdiff[$i]=$(($there - $here))
printf "$format1" ${city[$i]}
for j in `seq $myday`
do
printf "$format2" $(($j+${tdiff[$i]}))
done
printf "(%+d)\n" ${tdiff[$i]}
done
You can either use to check the time differences today or in a future date:
16:08 $ meet
January 22, 2019
Here 08 09 10 11 12 13 14 15 16 17 18 19 20
Toronto 05 06 07 08 09 10 11 12 13 14 15 16 17 (-3)
Chicago 04 05 06 07 08 09 10 11 12 13 14 15 16 (-4)
Amsterdam 11 12 13 14 15 16 17 18 19 20 21 22 23 (+3)
Dublin 10 11 12 13 14 15 16 17 18 19 20 21 22 (+2)
16:13 $ meet 05-24
May 24, 2019
Here 08 09 10 11 12 13 14 15 16 17 18 19 20
Toronto 07 08 09 10 11 12 13 14 15 16 17 18 19 (-1)
Chicago 06 07 08 09 10 11 12 13 14 15 16 17 18 (-2)
Amsterdam 13 14 15 16 17 18 19 20 21 22 23 24 25 (+5)
Dublin 12 13 14 15 16 17 18 19 20 21 22 23 24 (+4)
16:13 $
HTH
fantastic script! already added to my toolset, thanks! do you think it is possible to render time in columns instead of rows? – cesarpachon – 2019-05-24T12:29:59.367
Maybe. I don't see a use for that, though. – Iuri Gavronski – 2019-07-26T21:22:49.310
What do you mean exactly? Command line linux? Command you can type into Google? What?! – Dal Hundal – 2010-07-16T09:37:39.763
command line in shell and google's query box are both a command line to me – hendry – 2010-07-16T09:42:03.013
1perhaps a better tool would do cities by airport codes, 5pm LHR in SFO – hendry – 2010-07-16T09:42:35.697
@hendry dateutils can do timezone conversion based on iata and icao airport codes:
dateconv 2017-05-16T17:00 --from-zone iata:SFO --zone iata:LHR
->2017-05-17T01:00:00
– hroptatyr – 2017-05-16T09:10:01.880