Server time

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ivan

    Server time

    Hi,
    let's say that my server time is for some reason incorrect! Is there a php
    function that would automaticly correct that time (give or take a few
    minutes, hours, days...) so date() function would return real
    time/date!!

    Thanks,
    Ivan

    --
    EOF
  • Marcel

    #2
    Re: Server time


    "Ivan" <dedamraz@flyAW AY-SPAM.srk.fer.hr > schreef in bericht
    news:slrnbng4o4 .5f0.dedamraz@f ly.srk.fer.hr.. .[color=blue]
    > Hi,
    > let's say that my server time is for some reason incorrect! Is there a php
    > function that would automaticly correct that time (give or take a few
    > minutes, hours, days...) so date() function would return real
    > time/date!!
    >
    > Thanks,
    > Ivan
    >
    > --
    > EOF[/color]

    As alternative you can play some with atomic times obtained from
    timeservers:

    The script below displays the 'real' time obtained from a timeserver and the
    servertime on the providers server....

    <?php

    $server = "time.nist.gov" ;

    $fp = fsockopen($serv er, 37);

    $time = fread($fp, 4);

    fclose($fp);

    echo "Timestamp timeserver: ".hexdec(bin2he x($time))."<BR> <BR>";

    echo "Local timestamp on server provider: ".(time() +
    2208988800)."<B R><BR>";

    echo "Atomic time: ".strftime("%c" , hexdec(bin2hex( $time)) -
    2208988800)."<B R><BR>";

    echo "Local time on server provider: ".strftime("%c" , time())."<BR><B R>";
    ?>

    Marcel


    Comment

    • Ivo

      #3
      Re: Server time

      "Ivan" <dedamraz@flyAW AY-SPAM.srk.fer.hr > wrote in message
      news:slrnbng4o4 .5f0.dedamraz@f ly.srk.fer.hr.. .[color=blue]
      > Hi,
      > let's say that my server time is for some reason incorrect! Is there a php
      > function that would automaticly correct that time (give or take a few
      > minutes, hours, days...) so date() function would return real
      > time/date!![/color]

      Perhaps your server is in a different timezone that you are?
      If this is the case, simply adding/substracting the appropriate number of
      hours will work as long as daylightsavingt ime doesn't change at different
      times in your respective zones.
      Ivo


      Comment

      Working...