[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-db
Subject:    [PHP-DB] Re: Subject: php date/time zone
From:       "Neil Smith [MVP, Digital media]" <php () comatose ! freeserve ! co ! uk>
Date:       2009-03-19 21:47:30
Message-ID: 85.02.55398.CEAB2C94 () pb1 ! pair ! com
[Download RAW message or body]

At 04:57 19/03/2009, you wrote:
>Message-ID: <49C1D0C8.30109@silverbackasp.com>
>Date: Thu, 19 Mar 2009 12:57:44 +0800
>From: Ron <ron@silverbackasp.com>
>Subject: php date/time zone
>
>Hi All,
>
>I have a form where in a user will enter a time and choose a timezone.
>
>based on those, i need to insert to db the time as the actual time 
>on their timezone. how can i compute that on php? is it possible?


You can either do it in MySQL, by storing the UTC time of the action, 
and a timezone offset :
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_convert-tz

Or you could take Keith Devens approach and handle it in PHP :
http://keithdevens.com/weblog/archive/2004/Jul/28/Times.PHP.MySQL based on
http://keithdevens.com/weblog/archive/2004/Jul/15/MySQL.time previous post

To determine the users timezone *for* them, in the web page a little 
javascript would often be able to help set the timezone of a dropdown.
http://www.webmasterworld.com/forum13/3922.htm then either use that 
to select the selected option of a <select /> dropdown menu, or put 
it directly into a hidden field and trust that it's probably as right 
as you can get it.

The browser may also send header fields which could be used for this 
(in POST or PUT requests only) but it's not guaranteed or reliable either.

So the best approach would probably be to automatically set the 
timezone selection using javascript, but allow the user to modify it 
before posting the form

HTH
Cheers - Neil



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic