Date Time Zone Conversion (backwards of what I want)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Date Time Zone Conversion (backwards of what I want)
# 1  
Old 04-13-2015
Date Time Zone Conversion-updated (new problem)

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).

Code:
$ 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

Last edited by Michael Stora; 04-13-2015 at 08:20 PM..
# 2  
Old 04-13-2015
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:

Code:
TZ="Europe/Dublin" date

This User Gave Thanks to jlliagre For This Post:
# 3  
Old 04-13-2015
Try:

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

This User Gave Thanks to Chubler_XL For This Post:
# 4  
Old 04-13-2015
Quote:
Originally Posted by jlliagre
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:

Code:
TZ="Europe/Dublin" date

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.

Code:
$ 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.

Code:
$ 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

Last edited by Michael Stora; 04-13-2015 at 08:16 PM..
# 5  
Old 04-13-2015
Ireland is currently UTC+1 while Phoenix is UTC+7 so the date displayed is correct.
This User Gave Thanks to jlliagre For This Post:
# 6  
Old 04-13-2015
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.

Code:
$ 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
# 7  
Old 04-13-2015
There is actually no need to quote them at all anywhere.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Date and time change in global and non global zone

Hi, If I change date and time in global zone, then it will affect in non global zones. During this process what files will get affect in non global zones and which mechanism it's using to change. gloabl zone:Solaris 11.3 X86 TIA (1 Reply)
Discussion started by: Sumanthsv
1 Replies

2. Solaris

showing 2 different time zones in global zone and nonglobal zone

can some one help me out as it is showing 2 different time zones in global zone and nonglobal zone .In global zone it is showing in GMT while in nonglobal zone i it showing as PDT. System in running with solaris 10 (3 Replies)
Discussion started by: ravijanjanam12
3 Replies

3. Solaris

modifying date and time and time zone on solaris 5.10 with (redundant server) veritas

I have a cluster of two Solaris server (veritas cluster). one working and the other is standby I am going to change the date on them , and am looking for a secure solution as it is giving an important service. my opinion is that the active one doesn't need to be restarted (if I don't change the... (1 Reply)
Discussion started by: barry1946
1 Replies

4. Shell Programming and Scripting

Date Time Change for a particular target Zone

Hi Summary: - Script will take 2 arguments - Argument 1: Date/Time value in a particular format - Argument 2: TimeZone value Examples: Argument 1: a. "May 11, 2012 08:00:00 AM" b. "Dec 21, 2012 12:21:12 PM" c. "Oct 2, 2012 05:00:00 PM" Argument 2: a. MT or MST or MDT b. ET c.... (4 Replies)
Discussion started by: anuragpgtgerman
4 Replies

5. Shell Programming and Scripting

Military type format date/time conversion

Hello All, I have a requirement to convert a 12 hour format to 24 hour time format and the sample input /out put is below Input Time format : Nov 2 2011 12:16AM Out Put Format : Nov 2 2011 0:16 Input : Nov 2 2011 4:16PM Out Put: Nov 2 2011 16:16 I have done this using a... (6 Replies)
Discussion started by: jambesh
6 Replies

6. Programming

How to search a file based on a time stamp backwards 10 seconds

Hi all, I'm after some help with this small issue which i'm struggling to work out a fix for. I have a file that contains records that all have a time stamp for each individual record, i need to search the file for a specific time stamp and then search back 10 seconds to see if the number... (2 Replies)
Discussion started by: sp3arsy
2 Replies

7. Shell Programming and Scripting

Getting date output based on time zone

Hi, We have a server in US and hence while the command "date" is given it gives the output in EDT. If I want the date output in MET, how can I get it. Please let me know how I could do it in the script which is ksh. Thanks. (1 Reply)
Discussion started by: jmathew99
1 Replies

8. Homework & Coursework Questions

Date comparison with 'string date having slashes and time zone' in Bash only

1. The problem statement, all variables and given/known data: I have standard web server log file. It contains different columns (like IP address, request result code, request type etc) including a date column with the format . I have developed a log analysis command line utility that displays... (1 Reply)
Discussion started by: TariqYousaf
1 Replies

9. Shell Programming and Scripting

conversion from EPOCH timestamp to local time zone

hello gurus, i want a perl/shell script which once invoked should convert a set of EPOCH timestamps to local time ( IST..i want) . how does it work ,i have an idea on that..but writing a perl/shell script for it is not possible for me...so i need help for the same. my exact requirement is... (2 Replies)
Discussion started by: abhijeetkul
2 Replies

10. UNIX for Advanced & Expert Users

Translate date value to normal date and backwards.

Hello, How do i translate datevalues in unix to normal dates. and how do i translate normal dates in to datevalues. I'm using the unix-date. Sample: 1067949360 to 4-11-03 12:36 and 4-11-03 12:36 to 1067949360 I want to built a script with a question to the user: give in date... (4 Replies)
Discussion started by: Frederik
4 Replies
Login or Register to Ask a Question