Setting Local Time Zone on cPanel hosting which works for PHP date() function

Discussion in 'PHP' started by techbongo, Apr 26, 2011.

  1. #1
    Hi,

    I'm using cPanel shared hosting and not able to find an option to set my local timezone/time offset. So, whenever I try to track time on my site using PHP date() function, I used to get server date/time (PST) instead of my local time (IST). It's highly inconvenient for me and my website users, since tracing the correct local time for users' activity is really important for me.

    Please suggest a solution for this. Can this setting/configurations be changed anyhow on standard cPanel hosting? If not, how can I do it using PHP. I have a config file which is used (included at the begining) in all the PHP files of my site. So, I can put a piece of code snippet in that config file to make a site-wide change. Please guide me.
     
    techbongo, Apr 26, 2011 IP
  2. bogi

    bogi Well-Known Member

    Messages:
    482
    Likes Received:
    16
    Best Answers:
    2
    Trophy Points:
    140
    #2
    bogi, Apr 26, 2011 IP
  3. techbongo

    techbongo Active Member

    Messages:
    309
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    80
    #3
    Thanks for the info.
    If I use this function to set the correct timezone, will it work script-wide? I mean, if I call this function (to set my local timezone) at the beginning of the php file, will all the date() function calls return the local time?
     
    techbongo, Apr 27, 2011 IP