bob dylan
bob dylan

Reputation: 1109

Show current time of most commons timezone (UTC, EDT, CEST...)

I can have UTC current time with "date -u". But i would like to print the current time of some common timezones at the same time. (UTC, EDT, CEST...)

I can create a script and add severals :

date -u -d 'x hour ago'

But sometimes, hours change. (Like in France) Is there another solution to have the "real" current time, based on the country / cities maybe ?

EDIT : Here what i have done with the answer :

function dateall(){
    echo -n "US Pacific : " && TZ=US/Pacific date
    echo -n "US Eastern : " && TZ=US/Eastern date
    echo -n "UTC ~ GMT : " && date -u
    echo -n "Europe Paris : " && TZ=Europe/Paris date
    echo -n "Asia Bangkok : " && TZ=Asia/Bangkok date
}

Upvotes: 0

Views: 1115

Answers (2)

hroptatyr
hroptatyr

Reputation: 4829

In my dateutils there's datezone to do what you want in one simple command:

$ datezone now Europe/Paris US/Pacific US/Eastern UTC
2015-06-12T08:23:32+02:00   Europe/Paris
2015-06-11T23:23:32-07:00   US/Pacific
2015-06-12T02:23:32-04:00   US/Eastern
2015-06-12T06:23:32+00:00   UTC
2015-06-12T13:23:32+07:00   Asia/Bangkok
$

with the additional advantage that you also get the current UTC offsets and the times are guaranteed to coincide, i.e. the current time is determined only once and then used for all timezone conversions.

Upvotes: 1

lcd047
lcd047

Reputation: 5861

You can point TZ to the timezone you want:

$ TZ=Europe/Paris date
Fri Jun 12 07:41:28 CEST 2015

Upvotes: 3

Related Questions