2

I need to convert time from localtimezone (CET/CEST) to Sydney timezone (AEDT/AEST). I tried something like this:

export date=$(date "+%Y-%m-%d %H:%M:%S AEDT")
date "+%Y-%m-%d %H:%M:%S %Z" -d "$date"

It doesn't work, it doesn't recognize "AEDT", however I tried this with "UTC" and it worked. I tried to replace "AEDT" with "Australia/Sydney" (I found it in /usr/share/zoneinfos), but result was the same.

I would appreciate any advices, I am using korn shell. Thanks.

1

2 Answers 2

1

If you want to convert a random time from the local timezone to a time in another timezone:

$ date -d @$(date +%s -d '2014/10/01 12:34:56')
Wed Oct  1 12:34:56 CEST 2014
$ TZ=Australia/Sydney date -d @$(date +%s -d '2014/10/01 12:34:56')
Wed Oct  1 20:34:56 EST 2014

I use seconds since the unix epoch as the natural way to communicate a point in time.

0

Using a couple of scripting languages:

perl -MDateTime -E 'say DateTime->now(time_zone => "local")->set_time_zone("Australia/Sydney")->strftime("%F %T %Z")'

echo 'puts [clock format [clock seconds] -format {%Y-%m-%d %T %Z} -timezone ":Australia/Sydney"]' | tclsh

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .