1758264 Members
2596 Online
108868 Solutions
New Discussion юеВ

tztab

 
SOLVED
Go to solution
Mikael Filen
Occasional Contributor

tztab

I'm part of a project where we're building a web-based application. Users are going to connect from many different time zones and we want to display times taking the time zone where they live into consideration. Is it possible to use the information stored in tztab for this purpose? I know it's possible to enter a time zone in .profile to display correct time for a user, but in our system (to be) the users will be stored in our database. We would of course store their time zone along with all other user information. The system is coded in c++ and what we'd like to do is to get their local time by supplying their time zone. I'm sure someone has done something like this before.

thanks,

Mikael
4 REPLIES 4

Re: tztab

If each connected user is run as a seperate UNIX process, look to alter the environment for that user process - see environ(5)
That way all the hard work is done for you...

HTH

Duncan

I am an HPE Employee
Accept or Kudo
harry d brown jr
Honored Contributor
Solution

Re: tztab

Why not use ctime, tzset, and others by retreiving from your DB their TZ, then setting it? No need to reinvent the wheel?

live free or die
harry
Live Free or Die
Mikael Filen
Occasional Contributor

Re: tztab

ah ok... but how do i use tzset? As far as i can see the definition is void tzset(void) and it's supposed to read the environment variable TZ. Can i specify the time zone when using tzset. I've also seen mentioned a function called tzname. Is that the one to use? Could you give me a brief example?

I'm fairly new to hp-unix, hence the questions :)

thanks,

Mikael

Re: tztab

I guess you'd use putenv(3c) to set your environment - of course you need to remeber this will chnage this value for the whole user process, so be careful!

HTH

Duncan

I am an HPE Employee
Accept or Kudo