PHP Clock

Discussion in 'PHP' started by LmS, May 7, 2006.

  1. #1
    Hi all,

    Well I'm making an php clock, so far so good huh :p
    <?php
    echo "<meta http-equiv='refresh' content='1'>";
    echo "<font color='#999999' size='1' face='Verdana, Arial, Helvetica, sans-serif'>";
    echo date('G');
    echo ":";
    echo date('i');
    echo ":";
    echo date('s');
    ?>
    Well when the seconds change the whole page refreshes, yes i code it this way. Butt when i use this script on my web page, it refresh evrey second and then my visitor counter get's messed up. Some idea's ??

    I can't find it how to do it ...

    Please help me.
    PS: Sorry for my terrible english..

    Greetz,
    LmS
     
    LmS, May 7, 2006 IP
  2. JRJR

    JRJR Active Member

    Messages:
    172
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #2
    Why don't you use a javascript clock?
     
    JRJR, May 7, 2006 IP
  3. mines

    mines Well-Known Member

    Messages:
    1,127
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    160
    #3
    If you're going to keep requesting the time from the server, at least do it like with ajax or something ...

    and clocks on sites are hardly ever helpful (the ones that constantly update).

    And no </font>. And really the font tag isn't meant to be used any more, but that's getting off the topic tbh.
     
    mines, May 7, 2006 IP
  4. stuartc1

    stuartc1 Active Member

    Messages:
    125
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    75
    #4
    Ajax is probably the best method if you must do it. But I think you really should just use javascript. Imagine the extract traffic with a call every second (and what would happen if you have thousands of visitors on that page at the same time). Really not a good idea!
     
    stuartc1, May 7, 2006 IP
  5. frisby

    frisby Well-Known Member

    Messages:
    1,378
    Likes Received:
    39
    Best Answers:
    0
    Trophy Points:
    140
    #5
    Tottally true, ajax just in case, you really need it, for example for thinks, where you must do something (for example bettings), for homepage or that kind of page, js is cool.

    If you want, u can code js, that will get correct time from server (php will generate js) nad than just simulate clock. Soo easy.
     
    frisby, May 7, 2006 IP