Re: Subject: php date/time zone

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

 



At 04:57 19/03/2009, you wrote:
Message-ID: <49C1D0C8.30109@xxxxxxxxxxxxxxxxx>
Date: Thu, 19 Mar 2009 12:57:44 +0800
From: Ron <ron@xxxxxxxxxxxxxxxxx>
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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux