Re: Timezones

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
<tgryffyn@xxxxxxxxxxxxxxxxx> 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 '+0000' (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

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux