Time Conversion

Our Sun Solaris 10 machine is configured to use Hong Kong TimeZone and we are necessary to convert the currect time from HK time to NY Eastern Time in our application. Normally, we used the following codes to do so on Sun Solaris 8 and it works:

export TZ="/usr/share/lib/zoneinfo/US/Eastern"

/usr/bin/perl -e 'printf "%s\n",scalar localtime()'

But it did not work on Sun Solaris 10 (the NYT should be 13 hours lagging behind HKT)

On Sun Solaris 8 (correct):

server1:/usr/appadm >date

Fri Dec 8 16:34:02 CST 2006

server1:/usr/appadm >export TZ="/usr/share/lib/zoneinfo/US/Eastern"

server1:/usr/appadm >/usr/bin/perl -e 'printf "%s\n",scalar localtime()'

Fri Dec 8 03:34:09 2006

server1:/usr/appadm >

On Sun Solaris 10 (incorrect):

server1:/usr/appadm >date

Fri Dec 8 16:35:29 HKT 2006

server1:/usr/appadm >export TZ="/usr/share/lib/zoneinfo/US/Eastern"

server1:/usr/appadm >/usr/bin/perl -e 'printf "%s\n",scalar localtime()'

Fri Dec 8 08:35:37 2006

server1:/usr/appadm >

Anyone knows how to achieve it?

[1178 byte] By [Portal] at [2007-11-26 12:01:13]
# 1

Well, "date" defaults to GMT when it can't validate the data given to it by $TZ.

AFAIK the correct syntax for $TZ in this case would be "US/Eastern", and not /usr/share/lib/zoneinfo/US/Eastern

For example:

click(~):$ date

Fri Dec 8 11:01:33 CET 2006

click(~):$ env TZ="US/Eastern" date

Fri Dec 8 05:01:40 EST 2006

.. or...

click(~):$ env TZ="Hongkong" date

Fri Dec 8 18:04:18 HKT 2006

.7/M.

mAbrante at 2007-7-7 12:24:37 > top of Java-index,Solaris Operating System,Solaris 10 Features...