SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: server timezone

  1. #1
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    server timezone

    I might be switching to a webhost (reseller account) located in TX, and I live and do most of my business on the east cost (in eastern time).
    Obviously when getting the server time using PHP I could manually calculate the offset everytime, but thats annoying.
    I was wondering if there is some better way I could specify a timezone, keeping in mind that its a shared server.

    thanks!

  2. #2
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why not set up your own time() function and just plus/minus 60*x?

  3. #3
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks yeah, obviously on a per app basis thats fine...
    i was trying trying to see if I could do it without having to change all my existing code...
    its not really a big deal i suppose.

  4. #4
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://ca.php.net/manual/en/function.ini-set.php

    Seems it has:
    date.default_latitude"31.7667"PHP_INI_ALLdate.default_longitude"35.2333"PHP_INI_ALLdate.sunrise_zenith"90.83"PHP_INI_ALLdate.sunset_zenith"90.83"PHP_INI_ALLdba.default_handler""PHP_INI_ALL
    If you can figure out what those mean, that might help.. not entirely sure to be honest, just figured I'd let you know.

  5. #5
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    haha yeah thanks.
    prob is, if i were to change the actual ini file that would effect everyone on server. if i use ini_set I gotta put it in every file (as far as I know)...

    thanks for the suggestions

  6. #6
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't include some sort of header file? This has the same dependancies as making your own time() function, except you don't need to modify any of your code - just place a line, and remember to do that in all your scripts.

  7. #7
    SitePoint Wizard bronze trophy JRMillion's Avatar
    Join Date
    Apr 2004
    Location
    Arlington VA
    Posts
    2,094
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you're right, im just being lazy
    thats what ill end up doing thanks

  8. #8
    chown linux:users\ /world Hartmann's Avatar
    Join Date
    Aug 2000
    Location
    Houston, TX, USA
    Posts
    6,455
    Mentioned
    11 Post(s)
    Tagged
    0 Thread(s)
    Maybe a function that has predefined offsets would be the best idea. You could always use the GMT and put your offset as one of the arguments. Like:

    PHP Code:
    $zone 3600 * -// EST 
    $date gmdate('D M Y H:i'time() + $zone); 
    Set that up somewhere so that it can be used over and over and you're set. The only thing you have to worry about then is daylight savings.

  9. #9
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I am just researching this for a client now. The only solution I have come across so far is to:

    1) Add this value in the virtualhost config in httpd.conf

    php_value auto_prepend_file /home/user/timezone.php

    2) /home/user/timezone.php:

    PHP Code:
    <?php putenv('TZ=UTC+X'); ?>
    where X is the number of hours to offest (note +X or -X as required). Make sure there is no whitespace before or after the php tags!


Bookmarks

Posting Permissions

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