Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Time is a wee bit off...

    Umm...I think the time's a wee bit off...7 hours I think:
    $time = date("D, F j, g:ia");
    I guess this is server time in Atlanta...but I'm in Colorado.
    How would I change it without bloating?
    Thanks
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #2
    Regular Coder
    Join Date
    May 2003
    Location
    34° 54' N 82° 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This might sound off-topic, but why not use the JavaScript date function? It will show the time of the users computer instead of the servers time

    Just my thought......
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    $timeis date('G') - 7;
    echo 
    $timeis
    See if you can work from that. It's untested but in my drunken state, it should work in theory (PS, that's showing 24 hour hours) See http://uk.php.net/date for more help
    Last edited by Nightfire; 09-27-2003 at 04:55 AM.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    wouldn't that show -5 if it was 2am?

    $time = date("D, F j, g:ia", time()-25200);
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts
    What time do you think is best to use as a reference point in der States?
    I'll give it a shot...
    Thx
    PS - Maybe it's Miller time...
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts
    What I'm really looking for is a complete php time/date script that can be included which actually automatically corrects for daylight savings time, finds the correct time regardless of server time, and possibly knows where the user is and corrects for their time...but then again, I'm looking for world peace, too.
    Last edited by zoobie; 09-28-2003 at 12:35 AM.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #7
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, it should be doable. You can grap the users IP, then run a NetGeo search and determinde the regione and timedifference.

    There are quite some netgeo classes out there, but about half of the queries returns empty . It's a shame.
    If it's important to you, you could spend 50$ and get a GeoSelect developpers account.
    http://www.geobytes.com/Solutions.htm
    (look at the bottom, you can return the timezone, and if that isn't accurate enough, also the latitide-longitude)

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ugh...That geobytes includes everything but time zones...
    How about if I threw out the time zone location and just set it to EST? So, then it would just need to find the correct time regardless of server time and automatically correct for daylight savings time...A complete set-it-and-forget-it script...
    What say?
    Thanks
    Last edited by zoobie; 09-28-2003 at 12:50 AM.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Handling different time zones and their various daylight saving times is rather difficult. You can change the timezone on linux boxes by setting a certain environment variable. Maybe this works for you on your server (provided it actually is running linux as OS):

    PHP Code:
    putenv("TZ=America/Denver" );
    print 
    strftime ("%R"); 
    De gustibus non est disputandum.

  • #10
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by zoobie
    Ugh...That geobytes includes everything but time zones...
    I read it returns this (in relation to the IP's city):
    HTTP_GEOBYTESCITYID
    HTTP_GEOBYTESCITY
    HTTP_GEOBYTESLATITUDE
    HTTP_GEOBYTESLONGITUDE
    HTTPP_GEOBYTESTIMEZONE

    But i'm a bit unclear about what you try to do.
    With javascript you van grab the users datetime (thoug you'll get nothing for about 10% of the users) or you can ask them about there timesettings (when they register or whatever)

    When i'm browsing a site, i really don't need the machine to tell me exactly what time it is. I think you're making it hard on yourself to deliver something the clients isn't interested in. Just my opinion.

  • #11
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Well, I've got it going using mordred's suggestion of strftime() with the %Z for MDT...I guess I'll have to wait another month to see if it changes to MST along with the time, of course.
    Where's an online list of locales? I may want to use NYC for EST.
    Thanks...Works like a charm...I think.

    P.S. - I'm not being hard on myself...Actually, this hopefully will take care of "spring forward" and "fall back" time changes automatically 'till the year 2035...heh heh.

    P.S.S. - You wouldn't believe the amount of selections available for that function...There's another page with another 30 or so...They must have sat around for a couple of years figuring it all out...It's about time...hee hee.
    Last edited by zoobie; 09-28-2003 at 12:38 PM.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #12
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts
    It must get it's time from the internet somewhere because it's showing correct Denver time.
    I wonder if America/Pacific or America/Eastern wood work...
    Last edited by zoobie; 09-29-2003 at 12:11 PM.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #13
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I found the timezones for the lower 48...
    TZ=America/Los_Angeles
    TZ=America/Denver
    TZ=America/Chicago
    TZ=America/New_York

    ...but can't you set the TZ environment variable and all dates and times will appear correct for the user's timezone with an auto update?

    Running a Linux server...
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #14
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you have complete control over your linux server, you should be able to set the TZ environment variable through the shell. The exact command to do so doesn't come to my mind right now, but should be easy to find in the manpages/on the net.

    However, if you're on shared hosting, I'm afraid that's not gonna be working since you would change the timezone for everyone on that server... und understandably the user in Hawaii doesn't really like having his date() function suddenly return funky values.

    Maybe you could put the code I posted into a separate file and include that on every page you need - and to make this procedure easier you could do that automagically by using auto_prepend_file and setting that through a .htaccess file, as shown in the runtime configuration docs.

    Hope that helps.
    De gustibus non est disputandum.

  • #15
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,649
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Gotcha...Thanks
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">


  •  

    Posting Permissions

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