Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TZ script - interesting?

Status
Not open for further replies.

Olavxxx

Programmer
Sep 21, 2004
1,134
NO
Hi!

I've made a TimeZone script, is this interesting to other programmers?

I've thought about releasing it as GPL, but I think the way it is at the current state, it works PERFECT, but it's somewhat hard to integrate into the scripts the users might have.

If the interest is high, I might recode it to be more easy-to-implement.


it works very easy in backend:
*when user registers, he/she selects country from dropdown list (originally populated from iso3166 table).
*when user logs on, the system checks if the field TZ is NOT NULL. If it is null, the user did not choose timezone! Then run a natural join on iso3166 and another iso table, containing timezones. If numrows > 1, show dropdown list over awailible TZ, else: choose TZ as default.
*when the user then logs on, php uses the putenv to set TZ=timezone.. As we all know, mysql has no timezone! so then we use a mysql time function to subtract the difference between the server and the sql time, after putenv.

quite simple, really effective!

I use it on international members.. This way, they can easier relate to when other members where online!

ps. if only table designs are interesting, I posted them on some forum, I can try to locate it :p

night all!

Olav Alexander Mjelde
Admin & Webmaster
 
I am interested in this. Have you compiled the TZ for each country?

 
Hi,
it's based on ISO3166 countrycode, as well as a timezone table.

maybe I'll make a nice function for timezone :)
the problem with the timezone, is that the DB system is not affected by the putenv() -> TZ=

eg. one has to use timediff() or something like that in mysql too!

Though, smart thinking makes better coding.
I'm currently offline at home, but around the 28th, I'll get my 10mbit adsl2+, at my newly bought apartment.

if you'd like to cooperate or simply make something on your own, you can email me: olav-x at volvo-power.net

I think it might be cool to make a GPL script for TZ, as I think a lot of people need it.
it's veeeery simple, except the DB-part is a bit tricky to make dynamic maybe..

though, the basics are very basic :p

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top