Re: [PHP] Timezones
Thank you! I think this is what I needed. Regards, Venelin Robin Vickery wrote: On Mon, 22 Nov 2004 11:52:03 -0500, Gryffyn, Trevor <[EMAIL PROTECTED]> wrote: Then somewhere there has to be a cross reference between name and timezone info. I'm sorry I'm not running Apache here and don't have access to the same info that you're using, but I'd try digging into those config files and any database tables you can find that seem to relate to it. I'm sorry I can't be more help, but it's gotta be in there somewhere. Apache and PHP should be able to use your zoneinfo file, which contains the mappings for all these timezones. You can obtain the offset of the current timezone, using strftime('%z'). You'll get a return value like '+' (for GMT) or '+0200' (for EET) and '-0200' (for EST) etc. http://www.php.net/strftime You can change the current timezone by setting the 'TZ' environment variable with something like putenv("TZ=EST"). http://www.php.net/putenv You can find out the current setting of the 'TZ' environment variable with getenv('TZ'). http://www.php.net/getenv Putting that lot together, it's not hard to write a small function that given a timezone will return an offset from UTC (aka GMT). function tzOffset($tzUser) { $tzServer = getenv('TZ'); putenv("TZ=$tzUser"); $offset = strftime('%z'); putenv("TZ=$tzServer"); return $offset; } echo tzOffset('Canada/Newfoundland'); // -0330 echo tzOffset('EET'); // +0200 ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Timezones
On Mon, 22 Nov 2004 11:52:03 -0500, Gryffyn, Trevor <[EMAIL PROTECTED]> wrote: > Then somewhere there has to be a cross reference between name and > timezone info. I'm sorry I'm not running Apache here and don't have > access to the same info that you're using, but I'd try digging into > those config files and any database tables you can find that seem to > relate to it. I'm sorry I can't be more help, but it's gotta be in > there somewhere. Apache and PHP should be able to use your zoneinfo file, which contains the mappings for all these timezones. You can obtain the offset of the current timezone, using strftime('%z'). You'll get a return value like '+' (for GMT) or '+0200' (for EET) and '-0200' (for EST) etc. http://www.php.net/strftime You can change the current timezone by setting the 'TZ' environment variable with something like putenv("TZ=EST"). http://www.php.net/putenv You can find out the current setting of the 'TZ' environment variable with getenv('TZ'). http://www.php.net/getenv Putting that lot together, it's not hard to write a small function that given a timezone will return an offset from UTC (aka GMT). -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Timezones
Then somewhere there has to be a cross reference between name and timezone info. I'm sorry I'm not running Apache here and don't have access to the same info that you're using, but I'd try digging into those config files and any database tables you can find that seem to relate to it. I'm sorry I can't be more help, but it's gotta be in there somewhere. Maybe someone else can give you a better idea. I'm re-posting this to PHP General in case someone has any addition info. Sorry for the long-winded response that didn't really help. Hah. I didn't even consider the whole alphabetical thing, I should have noticed. Good luck! -TG > -Original Message- > From: Venelin Arnaudov [mailto:[EMAIL PROTECTED] > Sent: Monday, November 22, 2004 11:24 AM > To: Gryffyn, Trevor > Subject: Re: [PHP] Timezones > > > Hi Trevor, > > I am using Eclipse with a PHP plugin to modify my PHP system. > Actually > this system is based on the Source Forge but the guy that > made all the > modifications is not available any more and I am trying to > understand it > and perform some changes. > > The user.timezones field is modified by the user himself by selecting > the appropriate TZ from the list attached in my previous mail. I am > looking for a PHP function or script that would give me the offset of > each TZ in respect of GMT. As input parameter it should have > the string > TZ_name and as result the time (in hours, minutes or seconds). > > Using Excel does not help because in the list I have 466 > entries for 24 > whole hours and some half hours. I cannot apply any logic to > this list > because it is sorted alphabetically. But my Apache/PHP knows > perfectly > what is the time offset between the server and the user. And this is > based only on the TZ info stored in my apache config file and > the user > table. > > Kindest regards, > Venelin > > Gryffyn, Trevor wrote: > > >I did a quick search for some of the timezone names and > didn't quickly > >find a list that included the GMT offset (also called the UTC offset > >sometimes.. I think GMT and UTC are the same). > > > >BUT.. In general the timezones go hour by hour so if you > used something > >Excel (or some spreadsheet), created a list of your > timezones, found the > >offset of the first one, then did a +1 on the next one... > On down the > >list. That'd get you close to what you wanted. Then find a > decent list > >of offsets and insert rows where you have stuff like Indiana > or places > >that have a 1/2 hour offset. > > > > > >After that, I'd copy/paste the list into a good PHP editor that has > >macro functions (I use Crimson Editor > http://www.crimsoneditor.com) and > >record a macro to format the lines in such a way that ends > up building a > >new array in PHP. > > > >If you've never done this, it's easy. > > > >Say you start with some lines like this: > > > >$TZs[]='US/Alaska'; > >$TZs[]='US/Aleutian'; > >$TZs[]='US/Arizona'; > > > > > >You'd record a macro in Crimson Editor that does this: > > > >(1) > >$TZs[]='US/Alaska'; > > > >(2) > > before the US > >and hit DELETE> > >US/Alaska'; > > > >(3) > > > >US/Alaska > > > > > >You now have just your timezone... You may have a list like this > >already though. > > > >(4) > > >line>$TZs[]='US/Aleutian'; > > > >End macro recording. Now all you have to do is hold down (in Crimson > >Editor) the ALT-Macro# key (I reuse ALT-1 constantly) until > it finishes > >doing these actions to all lines. > > > > > >(5) Copy and paste this list into Excel or something > > > > > >Now after you get your numbers in Excel and you've adjusted > for the odd > >timezones. You'd do another macro like this: > > > >US/Alaska+1 > >US/Aleutian +2 > >US/Arizona +3 > > > >(when you paste from Excel into Crimson Editor, you should have TABs > >between the names and TZ #'s... Note, the TZ offsets listed > above aren't > >accurate, just using numbers as examples. There's no way Alaska is 1 > >hour ahead of GMT) > > > >(1) > >US/Alaska+1 > > > >(2) > >Enter something like: > >$tz[" > > > >So you end up with: > > > >$tz["US/Alaska +1 > > > >(2) > > cursor back > &
Re: [PHP] Timezones
On Fri, 19 Nov 2004 12:56:55 +0100, Venelin Arnaudov <[EMAIL PROTECTED]> wrote: > I have a legacy PHP3 system and a MySQL DB with two tables: > [...] > When a user submits a message, my PHP script (using time() function) > stores the submission time in messages.date field. However this value is > not the server's system time but shifted according the users timezone. > > 1. How can I convert it to reflect my timezone (ex. GMT)? Is there a way > to find the offset between two timezones given in long format as in my > table? MySQL assumes that the dates you supply are in your servers local timezone. You can convert dates from the users time to your local timezone using the builtin MySQL function CONVERT_TZ(datetime, from_tz, to_tz). See the MySQL manual for details: http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html#IDX1410 If you want to use "long format" timezones rather than offsets, you may have to do a little extra work with MySQL as the zoneinfo tables are not automatically loaded - the manual explains... http://dev.mysql.com/doc/mysql/en/Time_zone_support.html -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Timezones
Hi Trevor, I have list of Timezones (see the attachment) but I do not know the offset in respect of GMT. Then I will be able to calculate my local time for every user local input. I would like to know which PHP date/time functions operate with the system time alone and which one take the timezone into consideration. When in the function description is mentioned "local time" what does this mean? User local or system local? Kindest regards, Venelin Gryffyn, Trevor wrote: Don't know if this helps, but this was a message regarding Windows based long timezone formats that was posted a little while ago by another user: --- Kim [EMAIL PROTECTED] Managed to find it It helps using just those right keywords after a million goes http://www.steltor.com/notes/corptime-server/5_4/refmanual/refappd.htm this is a list of all timezone notations. Thanks for your help. Thought about the long way but it was not a pleasant thought as you may imagine, was hoping to avoid at all costs. Hopefully this sorts it. --- You might want to build a table or a list in some way that'll return the GMT offset for you. Let us know what you end up doing. -TG -Original Message- From: Venelin Arnaudov [mailto:[EMAIL PROTECTED] Sent: Friday, November 19, 2004 6:57 AM To: [EMAIL PROTECTED] Subject: [PHP] Timezones Hi, I have a legacy PHP3 system and a MySQL DB with two tables: user { user_id int, timezone varchar (like "Europe/Brussels", "US/Eastern", "America/New_York", etc.) } and messages { msg_id int, user_id int, date int } When a user submits a message, my PHP script (using time() function) stores the submission time in messages.date field. However this value is not the server's system time but shifted according the users timezone. 1. How can I convert it to reflect my timezone (ex. GMT)? Is there a way to find the offset between two timezones given in long format as in my table? 2. I would appreciate any information on how the PHP/Apache handles the timezone offset when calculating the time. Which of the PHP date/time functions take into consideration the environment variable TZ (upon user login there is putenv('TZ='.user_get_timezone()); command)? Thank you in advance, Venelin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Timezones
Don't know if this helps, but this was a message regarding Windows based long timezone formats that was posted a little while ago by another user: --- Kim [EMAIL PROTECTED] Managed to find it It helps using just those right keywords after a million goes http://www.steltor.com/notes/corptime-server/5_4/refmanual/refappd.htm this is a list of all timezone notations. Thanks for your help. Thought about the long way but it was not a pleasant thought as you may imagine, was hoping to avoid at all costs. Hopefully this sorts it. --- You might want to build a table or a list in some way that'll return the GMT offset for you. Let us know what you end up doing. -TG > -Original Message- > From: Venelin Arnaudov [mailto:[EMAIL PROTECTED] > Sent: Friday, November 19, 2004 6:57 AM > To: [EMAIL PROTECTED] > Subject: [PHP] Timezones > > > Hi, > > I have a legacy PHP3 system and a MySQL DB with two tables: > user { > user_id int, > timezone varchar (like "Europe/Brussels", "US/Eastern", > "America/New_York", etc.) > } > and > messages { > msg_id int, > user_id int, > date int > } > > When a user submits a message, my PHP script (using time() function) > stores the submission time in messages.date field. However > this value is > not the server's system time but shifted according the users timezone. > > 1. How can I convert it to reflect my timezone (ex. GMT)? Is > there a way > to find the offset between two timezones given in long format > as in my > table? > 2. I would appreciate any information on how the PHP/Apache > handles the > timezone offset when calculating the time. Which of the PHP date/time > functions take into consideration the environment variable TZ > (upon user > login there is putenv('TZ='.user_get_timezone()); command)? > > Thank you in advance, > Venelin > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Timezones and Daylight Savings Time
Hi, Friday, September 26, 2003, 2:55:51 AM, you wrote: JJ> Got a client site in Thailand that is about 13 hours JJ> different from the Web Server time so with any JJ> date/time stamping I need to add the 13 hours. JJ> However, when it comes time for DST, I'd hate to have JJ> to code for that or remember to manually change the JJ> time stamping. JJ> Is there some kind of automated function that JJ> determines the time zone of one location to another JJ> and stamps the correct time -- with or without DST? JJ> I guess otherwise you'd have to do something like: if >> Oct 31st and < April XX { time+12 } else { JJ> time+13 JJ> Obviously not the correct code but that's the idea. JJ> Am I off base here? Is there a simpler method or JJ> something I'm not thinking of? JJ> If the server was dedicated I would just fix the JJ> server time to be Thailand time, but it's a shared JJ> server and I can't do that. JJ> Thanks in advance! JJ> __ JJ> Do you Yahoo!? JJ> The New Yahoo! Shopping - with improved product search JJ> http://shopping.yahoo.com You could put this at the top of each page putenv('TZ=Asia/Bangkok'); That will correct all PHP functions, not sure about database times though -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Timezones and Daylight Savings Time
They want everything set to their time, so it would probably be easier just to determine the server time and add as necessary. I think... --- Jeff McKeon <[EMAIL PROTECTED]> wrote: > What if you set the server to use UTC and then used > the clients local > system setting to offset it for each client? > > So the server would have it's time at UTC and a > client in the Eastern US > would be at -4. You could then detect the web > client timezone setting > and adjust as needed? > > This is just a logic suggestion, I have no idea if > it's possible with > code but I would imagin it would be.. > > Jeff > > __ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Timezones and Daylight Savings Time
What if you set the server to use UTC and then used the clients local system setting to offset it for each client? So the server would have it's time at UTC and a client in the Eastern US would be at -4. You could then detect the web client timezone setting and adjust as needed? This is just a logic suggestion, I have no idea if it's possible with code but I would imagin it would be.. Jeff > -Original Message- > From: J J [mailto:[EMAIL PROTECTED] > Sent: Thursday, September 25, 2003 12:56 PM > To: [EMAIL PROTECTED] > Subject: [PHP] Timezones and Daylight Savings Time > > > Got a client site in Thailand that is about 13 hours > different from the Web Server time so with any > date/time stamping I need to add the 13 hours. > However, when it comes time for DST, I'd hate to have > to code for that or remember to manually change the > time stamping. > > Is there some kind of automated function that > determines the time zone of one location to another > and stamps the correct time -- with or without DST? > > > I guess otherwise you'd have to do something like: > if > Oct 31st and < April XX { time+12 } else { > time+13 > > Obviously not the correct code but that's the idea. > Am I off base here? Is there a simpler method or > something I'm not thinking of? > > If the server was dedicated I would just fix the > server time to be Thailand time, but it's a shared > server and I can't do that. > > Thanks in advance! > > > __ > Do you Yahoo!? > The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] timezones
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]
Re: [PHP] timezones
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. they still could be just make your pst offset be 0 and every timezone offset be the difference in hours between them and pst*3600 >2.) we have users ALL OVER the world - is there a place to find all >of the timezones at? good luck, there's tons and some of them are wacky or don't honor daylight saving time. > >--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: php-list- >[EMAIL PROTECTED] -- 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]
Re: [PHP] timezones
http://www.worldtimeserver.com/ has them all..then you can just assign your constants to them in a way that makes sense to you - Original Message - From: "Joe Stump" <[EMAIL PROTECTED]> To: "Mark Maggelet" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Monday, April 30, 2001 3:24 PM Subject: Re: [PHP] timezones > 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] > -- 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]
Re: [PHP] timezones
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]
Re: [PHP] timezones
I would use gmktime() to create a UTC timestamp stored in the database, and then use the knowledge about each users timezone to convert this information when showing it. - Frank > 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. > > 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: [EMAIL PROTECTED] > > > -- 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]
Re: [PHP] timezones
This is how I do it: in DB: usertable username,etc,tzone where tzone = EST,PST,MNT,CNT when the user logs in just grab the tzone, register it in the session. Also make them constants, so you know if the server is in CA, then EST = 10800 now when they do something, all you have to do is calc the time. Like result = mktime() - EST Is this what you were talking about? Jon - Original Message - From: "Joe Stump" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, April 30, 2001 2:56 PM Subject: [PHP] timezones > 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. > > 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: [EMAIL PROTECTED] > -- 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]
Re: [PHP] timezones
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] -- 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]