#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,664
    Rep Power
    171

    Dynamically set date_default_timezone_set


    Hi;

    How can I ge user's location (maybe by IP?) and dynamcally set date_default_timezone_set to that area?

    Thanks
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    google for "geolocation".
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  4. #3
  5. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    If your application stores dates of any sort in your database you shouldn't do this, it will make handling the dates more complicated. Your PHP script should always run with the same timezone, and your database should always store dates in that same timezone; otherwise querying by date becomes a massive and slow nightmare. It doesn't matter what timezone you use, but UTC is the defacto choice.

    There are ways of gathering information about the visitor's location / timezone which could be used to automatically change the timezone used to display dates. However, you should still give users the option to manually set a timezone; first because they might not currently be in the timezone they want to see (ex: if they are traveling) and second because no method of determining the user's location or timezone automatically is 100% accurate.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo