Re: How to show proper time to users from around the world

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

 



On 8/29/07, Hemanth <mvhemanth@xxxxxxxxx> wrote:
> Hi friends,
>
> Is there a solution to showing the proper time and date at user
> browsers
> and also recording proper USER times in the database operations in
> mysql

if you have the opportunity to have them input the time, you can then use

putenv("TZ=America/Los_Angeles") before any time operations and they
will be localized. it will accept any of the timezone library
definitions (or what you select for instance on unix libraries)

there's also a new date extension available as of one of the latest
php versions i believe that makes it even easier.

http://us3.php.net/manual/en/ref.datetime.php has the info.

for mysql data exchange you can use FROM_UNIXTIME and
UNIX_TIMESTAMP(NOW()) for example; if you dig it out from the database
and use the PHP functions it will localize it properly still. i don't
even fuss with this stuff anymore, i have a date formatting function
which takes $visitor['timezone'] (which is pre-populated with a
default, and overridden if the user has defined a different one) and
uses putenv("TZ=$foo") before i do the actual date/function calls -
it's been working flawlessly for years. i could probably update it now
to use the new extension too, natively maybe it would work slightly
faster than environment setting.

trying to detect the timezone offset from the browser i do not think
can be done consistently. i don't think i've seen anything that is
considered foolproof for that. maybe just DST checks...

-- 
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