Date Time Zone Conversion (backwards of what I want)

I am trying to convert local time to time in Ireland. Instead it is going the opposite direction (taking the local time as it if were in Ireland and displaying that the time would be here).

$ echo "$TZ"; date; date --date='TZ="Europe/Dublin" '"$(date)"
America/Phoenix
Mon, Apr 13, 2015 15:20:05
Mon, Apr 13, 2015 07:20:05

It is actually 23:20 in Ireland.
Anyone have any ideas?

Mike

It is unclear why you want to convert your local time to the time in Ireland. If what you really want is to display the current time in Ireland, the proper command would be:

TZ="Europe/Dublin" date
1 Like

Try:

$ TZ="Europe/Dublin" date
Mon, Apr 13, 2015 11:27:51 PM
1 Like

That was just for the example. I am actually converting a date read from a text document.

Thanks to both of you.

Mike

---------- Post updated at 03:50 PM ---------- Previous update was at 03:42 PM ----------

Opps! Not working in my script to convert a known date.

$ TZ="Europe/Dublin" date
Mon, Apr 13, 2015 23:48:19

TZ="Europe/Dublin" date --date='Mon, Apr 13, 2015 23:48:19'
Mon, Apr 13, 2015 23:48:19

Mike

---------- Post updated at 04:03 PM ---------- Previous update was at 03:50 PM ----------

Getting closer. My initial thinking was not far off. I am one hour short of the mark.

$ TZ="Europe/Dublin" date --date='TZ="America/Phoenix" Mon, Apr 13, 2015 16:01:00'
Tue, Apr 14, 2015 00:01:00

Is there a bug in date? The tz database lists Americas/Phoenix as UTC -7:00, UTC DST -07:00 and Eurpoe/Dublin as UTC +00:00, UTC DST +01:00.

Mike

Ireland is currently UTC+1 while Phoenix is UTC+7 so the date displayed is correct.

1 Like

Thanks. Time zone is very picky about when it needs quotes (leaving them out often brakes it). In my case adding extras was causing it to revert to UTC without warning.

$ timeZone='"Europe/Dublin"'

$ TZ="$timeZone" date --date='TZ="America/Phoenix" 04/13/2015  04:44 PM'
Mon, Apr 13, 2015 23:44:00

$ timeZone='Europe/Dublin'

$ TZ="$timeZone" date --date='TZ="America/Phoenix" 04/13/2015  04:44 PM'
Tue, Apr 14, 2015 00:44:00

Mike

There is actually no need to quote them at all anywhere.

$ timeZone='Europe/Dublin'
 
$ TZ="$timeZone" date --date='TZ="America/Phoenix" 04/13/2015 04:44 PM'
Mon, Apr 13, 2015 23:44:00
 
$ TZ="$timeZone" date --date='TZ=America/Phoenix 04/13/2015 04:44 PM'
date: invalid date �TZ=America/Phoenix 04/13/2015 04:44 PM�
 
$ TZ="$timeZone" date --date=TZ=America/Phoenix 04/13/2015 04:44 PM
date: extra operand �04:44�
Try 'date --help' for more information.

Mike