Wanted to thank everyone for the insights for some of this date/time issues!
Pretty much what I was looking at, just wanted a little confirmation!
I will also need to research that PHP function -

Thanks - Chris


On 3/6/07, Marcus Bointon <[EMAIL PROTECTED]> wrote:
On 6 Mar 2007, at 17:12, David T. Ashley wrote:

> Best practice is that all times maintained in a database (or
> anywhere on the
> server) are UTC, and are only converted to local timezone and/or
> adjusted to
> daylight savings time as required to display data for a specific user.

Exactly right.

> Now, as far as the best way to implement the two paragraphs above
> (especially with DST), I have not a clue.

I do this using the date extension that was updated in PHP 5.1. I
store the string representation of the time zone, for example 'Europe/
London', and set that as the time environment whenever a session is
started using: http://www.php.net/manual/en/function.date-default-
timezone-set.php
After that it all just magically works - whenever you call date() and
friends, it's all corrected for the time zone.

A slightly harder question is how to get the user's time zone in the
first place. You can take a wild guess according to their IP, but it
could well be wrong. Next you could use Javascript to find out the
local time and get an offset, but then you have no way of getting DST
info, and it doesn't tell you where they really are. Finally, you can
just ask - I've made the time zone a user preference, and most
systems I've seen do the same.

Marcus
--
Marcus Bointon
Synchromedia Limited: Creators of http://www.smartmessages.net/
[EMAIL PROTECTED] | http://www.synchromedia.co.uk/



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to