Operating System - HP-UX
1753436 Members
4553 Online
108794 Solutions
New Discussion юеВ

Problems of Different Time Zones on Applications

 
SOLVED
Go to solution
ericfjchen
Regular Advisor

Problems of Different Time Zones on Applications

Because we plan to establish manufacture sites in the different time zones (only one data center in the world),

we would like to refer to your practice of different time zones on applications.

Please kindly tell us how you resolved the following issues.

For example, if the server time zone corresponds to New York (GMT-5) and the client time zone corresponds to

San Francisco (GMT-8), the client finished a transaction on the data center web system at local time (12-Jun-2008 15:30:45)
then what value stored in the database?

1. server time as тАЬ12-Jun-2008 18:30:45тАЭ

2. client time with time zone as тАЬ12-Jun-2008 15:30:45 GMT-5тАЭ

3. others?

And what time will be displayed to the user?

1. server time as тАЬ12-Jun-2008 18:30:45тАЭ

2. server time with time zone as тАЬ12-Jun-2008 18:30:45 GMT-5тАЭ

3. client time as тАЬ12-Jun-2008 15:30:45тАЭ

4. client time with time zone as тАЬ12-Jun-2008 15:30:45 GMT-8тАЭ

5. others?


Thanks for your help.



8 REPLIES 8
Dennis Handly
Acclaimed Contributor
Solution

Re: Problems of Different Time Zones on Applications

>we would like to refer to your practice of different time zones on applications.

There is only one time, UTC or time_t.
Local times should be converted to UTC and then stored in the database. If you want to display the time, use ctime(3) and each locale would export different values of TZ.

>what value stored in the database?
>3. others?

Yes, UTC. 12-Jun-2008 22:30:45

>And what time will be displayed to the user?
>4. client time with time zone as "12-Jun-2008 15:30:45 GMT-8"

Yes since users are chauvinistic but with a zone, PDT.
Steven E. Protter
Exalted Contributor

Re: Problems of Different Time Zones on Applications

Shalom,

In such circumstances we use Greenwich Mean time.

Understand that time in Unix is really the number of seconds since Jan 1, 1970.

Time zone is merely a display format that will not bother most normally written applications.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
ericfjchen
Regular Advisor

Re: Problems of Different Time Zones on Applications

Dear All,

Is there any other exception?

Thanks

Eric
ericfjchen
Regular Advisor

Re: Problems of Different Time Zones on Applications

Hi Dennis,

>what value stored in the database?
>3. others?

Yes, UTC. 12-Jun-2008 22:30:45

--> It should be 12-Jun-2008 23:30:45 GMT ?

Dennis Handly
Acclaimed Contributor

Re: Problems of Different Time Zones on Applications

>ME: Yes, UTC. 12-Jun-2008 22:30:45

>It should be 12-Jun-2008 23:30:45 GMT?

Are you commenting about the missing "GMT"?
No, UTC is the official term.
$ date -u
Thu Jun 26 04:13:51 UTC 2008

If you are pointing out 22:30 vs 23:30, then I think I'm right. The local time here in the San Jose Bay Area is now:
$ date; date -u
Wed Jun 25 21:18:17 PDT 2008
Thu Jun 26 04:18:17 UTC 2008

Since it is PDT, UTC is only 7 hours more advanced.

>4. client time with time zone as 12-Jun-2008 15:30:45 GMT-8

This seems like that bogus Microsoft way of doing things. I.e. the timezone is normally UTC-8. But during DST, it is -7.
This is expressed on UNIX as PST8PDT. And times are printed as PST or PDT.

(Note San Francisco is that small town north of San Jose. ;-)
ericfjchen
Regular Advisor

Re: Problems of Different Time Zones on Applications

Hi Dennis,

Thanks a lot. Does your application provide a profile which every user can config his/her local time zone?

BTW, may I contact you via email?
If convenient, pls mail to ericfjchen@gmail.com
Matti_Kurkela
Honored Contributor

Re: Problems of Different Time Zones on Applications

HP-UX (or any POSIX-compliant unix-like OS) provides a mechanism that allows any user to change his/her timezone preference. It is the TZ environment variable.

In HP-UX, the system startup and login scripts initialize the TZ variable to a value specified in /etc/TIMEZONE. But this is just the system default (i.e. what the system services like cron and sendmail use in their logging).

Any user can modify the TZ environment variable for his/her session if necessary. The user can even run several programs using different timezones.

If you're using an X Window System, try these commands:
TZ=PST8PDT xclock &
TZ=EST5EDT xclock &
TZ=UTC0 xclock &

You now should have three xclocks telling you the time in three different timezones - with no options specified to the xclock command. Only the TZ environment variable was changed.
You can do this to any program which cares about time.

MK
MK
Dennis Handly
Acclaimed Contributor

Re: Problems of Different Time Zones on Applications

>Does your application provide a profile which every user can config his/her local time zone?

Well, I just use the standard UNIX TZ variable as MK explained.
(I don't have a specific application, nor do I use a database. But the compiler does store date info in object files.)

>may I contact you via email?

Unless you have something private, why not continue here.