If you want to do it correctly it is much more difficult to calculate
the TZ than you think. The problem is that different time zones shift
to daylight savings at different times and some do not shift at all.
Therefore simply adding the offset will work for a while and then you
will get problems in places like Arizona and parts of Indiana and you
will shift to daylight savings time a full week after your European
users.

The way I did this was to parse the time zone data available at
ftp://elsie.nci.nih.gov/pub/ and store it in a database. I then built
some functions that would calculate the correct offset depending on
the date (and time) passed in and another function that would apply
the offset.

They have some tools to do this in C and perl but I don't speak either
of them so I did it myself (unfortunately for you I didn't use PHP
either because the project I did this for is written in Progress 4GL.)

At an application level I determined that it is easier to convert
everything done on the server to GMT and store that and then to
convert from GMT to the user's local time zone for display. It becomes
much easier to calculate the offset because GMT never shifts to
daylight savings plus you only take a small performance hit every time
instead of the double conversion hit on display which may become
significant for something like a report.

It took about a weekend of work to set this up and then a couple of
hours here and there to tweak it so there is some significant work
involved but it is worth it. 

BTW: Based on the look and feel of worldtimeserver.com (and many
others like this) I would say that they are using the perl version of
this data.

Also: For some reason I am unable to bring up the FTP server I
referenced above. I was there the other day to get fresh data so I
know it is still valid. Try again later if you can't get to it.

Zane Appel

On Mon, 30 Apr 2001 14:24:20 -0500, Joe Stump <[EMAIL PROTECTED]>        
 wrote:

>Thanks to everyone who sent in the info. The problem is as follows:
>
>1.) the mktime()'s are stored as PST in the DB.
>2.) we have users ALL OVER the world - is there a place to find all of the
>    timezones at?
>
>--Joe
>
>On Mon, Apr 30, 2001 at 12:11:55PM -0700, Mark Maggelet wrote:
>> On Mon, 30 Apr 2001 13:56:20 -0500, Joe Stump ([EMAIL PROTECTED])
>> wrote:
>> >I have a quick question regarding timezones ...
>> >
>> >On the local side a record is inserted into the DB by someone in
>> >Michigan, while
>> >the server rests in CA. Thus a three hour difference. The local
>> >mktime() will
>> >create a timestamp for say 9:00am when in reality it was entered at
>> >12:00noon
>> >in MI. I have 2 character timezones for all my users so it should be
>> >easy to
>> >convert the two.
>> 
>> you could use gmmktime() instead and add or subtract the offset.
>> 
>> $offsets=array("
>> "PST"=>1000,  // not actual values
>> "EST"=>-2000,
>> ");
>> 
>> $localtime=gmmktime()+$offsets[$timezone];
>> 
>> >putenv() won't work because of the fact that the timestamp created
>> >will be
>> >9:00 no matter what timezone you put it in. So what needs to be done
>> >is some
>> >recognition that 10800 seconds needs to be added to adjust the PST
>> >timestamp
>> >to an EST timestamp. Are there any functions out ther that do this?
>> >
>> >--Joe
>> >
>> >Joe Stump <[EMAIL PROTECTED]>
>> >---------------------------------------------------------------------
>> 
>> >---
>> >One is taught by experience to put a premium on those
>> >few people who can appreciate you for what you are.
>> >
>> >
>> >--
>> >PHP General Mailing List (http://www.php.net/)
>> >To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >For additional commands, e-mail: [EMAIL PROTECTED]
>> >To contact the list administrators, e-mail: php-list-
>> >[EMAIL PROTECTED]
>> 
>
>Joe Stump <[EMAIL PROTECTED]>
>------------------------------------------------------------------------
>Dyslexics of the world  


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to