Some advice: I need to amend a script so script time is correct

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KarlBee
    Junior Member
    • Mar 2004
    • 9

    #1

    Some advice: I need to amend a script so script time is correct

    I was wondering if you could help me!

    I have a script that uses PHP 'time' features and need to make the script believe it is 7 hours ahaead of server time (Dathorn in USA and I am in UK)

    Is this easy to do? Can anyone assist in making this script adjust my time?

    This is amy script:

    PHP Code:
    <?php 
    $date 
    date("Ymd"); 
    $NumEvents=0
    $handle=opendir('../event_dates'); 
    while ((
    $file readdir($handle))!==false) { 

        if (
    $file >= $date) { 
           include(
    "../event_dates/$file"); 
           
    $NumEvents=$NumEvents 1
        } 

    closedir($handle);  

    if(
    $NumEvents 0
      { 
       echo 
    "$NumEvents events are scheduled"
      } 
    else 
      { 
      echo 
    "<strong class='red'>Sorry, no events are planned at present</strong>"
      } 

    ?>
    Thanks a lot
    Karl
  • Buddha
    Senior Member
    • Mar 2004
    • 825

    #2
    How about something like?

    PHP Code:
    $date date("Ymd"time()+3600*7); 
    "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

    Comment

    • KarlBee
      Junior Member
      • Mar 2004
      • 9

      #3
      Buddah,
      That did the trick

      I am pretty new to all this. I guess to take daylight saving time into the equasion makes things a whole lot harder.

      Thanks very much.
      Karl

      Comment

      • Buddha
        Senior Member
        • Mar 2004
        • 825

        #4
        Originally posted by KarlBee
        I guess to take daylight saving time into the equasion makes things a whole lot harder.
        Well it's not easier that's for sure. UK and USA daylight savings time are different.

        UK DST - Mar 28 to Oct 31
        USA DST - Apr 4 to Oct 31

        So between Mar 28 and Apr 4 we need to substract an hour and between Apr 4 and Oct 31 add an hour. Does that sound correct?

        Well then something like this...

        PHP Code:
        $dst 0;
        $tarr localtimetime(), );
        if ( (
        $tarr['tm_mon'] = && $tarr['tm_mday'] >= 28 && $tarr['tm_mday'] <= 31) || $tarr['tm_mon'] = && $tarr['tm_mday'] >= && $tarr['tm_mday'] <= 3) {
            
        $dst = -3600;
        } elseif ( (
        $tarr['tm_mon'] >= && $tarr['tm_mday'] >= ) && ($tarr['tm_mon'] <= 9)) {
            
        $dst 3600;

        $date date("Ymd"time()+$dst+3600*6); 
        No guarantee this will work though. It's just a thought.
        "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

        Comment

        • paulC
          Junior Member
          • Mar 2004
          • 20

          #5
          I'm in Japan and have a script that adjusts the time difference between the dathorn servers and our timezone, and takes daylight saving time into account. It might be useful. Mail me if you'd like to see it (it was written by another member of our team, so is not really mine to post publically).

          Comment

          Working...