Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: default timezone

  1. #11
    Scott's Avatar
    Scott is offline Certified Glow Sage
    Join Date
    Oct 2006
    Posts
    27

    Default

    After discussing this further off-line, I have come to the conclusion that I believe it would always be best to handle any recording of time into MySQL as GMT. Then to simply let PHP handle the displaying of time into your intended time zone.

    This would allow you to change the time zone domain wide by using the Apache directive. Then as Matt has pointed out and you have visitors that require the time to be displayed differently, you can override the default time zone set by Apache with PHP.

    As Mysql is concerned you can then make the adjustment on a per connection basis by setting the time zone to "0".

    I believe this would also aide in making your code more portable.

    This is my conclusion, any other thoughts or holes in my train of thought here?

  2. #12
    Matt's Avatar
    Matt is offline GlowHost Administrator
    Join Date
    Jan 2005
    Location
    Behind your monitor
    Posts
    5,929

    Default

    I think I too have heard that the way to do it is in fact, GMT. It does ring a bell anyways.

    The only portability problem I see is that not everyone uses Apache webserver.

    I suppose it would not much matter for you unless you plan on making this application for sale or distribution, and then, I still wonder. I think the more you can keep out of .htaccess the better though, because different web servers either do not read that file, or may interpret it differently than Apache does.

    Why not let PHP do all the time processing based on GMT in MySQL?
    Last edited by Matt; 03-14-2008 at 10:29 AM.
    Send your friends and site visitors to GlowHost and get $125 plus bonus!
    GlowHost Affiliate Program | Read our Blog | Follow us on X |

  3. #13
    Dmitriy is offline Nearly a Master Glow Jedi
    Join Date
    Feb 2007
    Location
    Ukraine
    Posts
    124

    Default

    Well, yes, PHP uses server local time. You can obtain if local server time is in DST (call date('I')). As for MySQL - it depends on configuration. Check MySQL manual: A.4.6. Time Zone Problems.

    However, from the PHP script you can't determine if (let's say the server is in Florida) if in New Ziland is used DST right now. See: About Daylight Saving Time. That is why many PHP applications have 'Use DST' in options (it simply adds 1 hour to the user timezone).

    JM, Scott, any comments?

    Very interesting situation arises, when user says his timezone is GMT +2 & he is in country that uses DST..... so what the current user time is? Anybody knows for sure?

  4. #14
    Dmitriy is offline Nearly a Master Glow Jedi
    Join Date
    Feb 2007
    Location
    Ukraine
    Posts
    124

    Default

    Finally, after few hours of searching, found & tested a script. Seems working good:
    Timezone and Daylight Saving Time Script
    However, I wasn't able to check many timezones... Have a look at it

  5. #15
    Matt's Avatar
    Matt is offline GlowHost Administrator
    Join Date
    Jan 2005
    Location
    Behind your monitor
    Posts
    5,929

    Default

    From his site:

    At the time of writing this, I am aware that the United States is considering passing legislation that would change their daylight savings time rules with Canada to possibly follow suit. Once these new rules are made official, I will make an effort to update this script to reflect the changes.
    I believe this was passed this year. Though I forget what it was, I think what it entailed was a change to the date that DST was recognized on.

    Can anyone confirm or deny that the changes have already been made?
    Send your friends and site visitors to GlowHost and get $125 plus bonus!
    GlowHost Affiliate Program | Read our Blog | Follow us on X |

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14