Help with a PHP script

Discussion in 'PHP' started by pipwax, Oct 7, 2007.

  1. #1
    Here is my script
    =========================code=============================
    <?php $hour = date("G");
    $today = date("g:i a");

    $msg = "Good Evening.";
    if($hour < 18) { $msg = "Good Afternoon."; }
    if($hour < 12) { $msg = "Good Morning."; }

    echo ("$msg The time is $now");

    ?>
    =======================end code============================
    I would like help on changing this script so that it will get the time from the users computer and not the server. Otherwise if I use it now a user that is on the east coast may get the wrong message, because the server is in the midwest.

    Thanks!
     
    pipwax, Oct 7, 2007 IP
  2. tarponkeith

    tarponkeith Well-Known Member

    Messages:
    4,758
    Likes Received:
    279
    Best Answers:
    0
    Trophy Points:
    180
    #2
    For client side programming, why not use JavaScript?
     
    tarponkeith, Oct 7, 2007 IP
  3. pluswebdev

    pluswebdev Banned

    Messages:
    205
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    @tarponkeith is right
    I think this is exactly for you: h ttp://javascript.internet.com/page-details/time-greeting.html

    if you still prefer to use PHP, you may try to use mktime() to correct server time with the time zone of your visitors
     
    pluswebdev, Oct 7, 2007 IP