Re: [PHP] Timezones

2004-11-23 Thread Venelin Arnaudov
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

2004-11-22 Thread Venelin Arnaudov
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

[PHP] Timezones

2004-11-19 Thread Venelin Arnaudov
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