Results 1 to 6 of 6

Thread: Clock with Text

  1. #1
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Clock with Text

    I currently have a clock on my website (php) that displays my local time zone.

    the only reason I have it there is for my international customers. I want them to see our local time so they know when we SHOULD be online or offline.

    Since some people in the world do not understand this I would like to add text "Online" and "Offline based on the current local time.

    From 8am until 12 am it should say Online and from 12:00:01 to 7:59:59 it should say Offline.

    Here is my code can someone please help me finish it?

    Code:
    <?php
    $hourdiff = "8"; // hours diff btwn server and local time
    $time = date("h:i a",time() - ($hourdiff * 3600));
    print ("$time");
    echo <br />
    ?>
    I would like it in this format:

    Current Local Time:
    12:56 am

    Support Offline



    Current Local Time:
    10:56 am

    Support Online


    Thank you for your help

  2. #2
    Join Date
    Nov 2005
    Posts
    40
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    <?php
    $hourdiff = "8"; // hours diff btwn server and local time
    $time = date("h:i a",time() - ($hourdiff * 3600));
    print ("$time");
    echo "<br />";
    $d=date(H);
    if ($d > 0 && $d < 4)
    echo "Support Online";
    else
    echo "Support Offline";
    ?>

    Try that. Change the digits in the if statement to work for your server time.

  3. #3
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thank you will do

  4. #4
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I actually had to edit this for the TIME not the date of the server.

    Since I our support is based on -8 (PST) here is the code I used and seems to be working

    Code:
    <?php
    $hourdiff = "8"; // hours diff btwn server and local time
    $time = date("h:i a",time() - ($hourdiff * 3600));
    print ("$time");
    echo "<br />";
    echo "<br />";
    if ($time > 8 && $time < 16)
    echo "<B>Support Online</B>"; 
    else
    echo "<B>Support Offline</B>"; 
    ?>
    seems to be working I will give it a run and try to remember to post if this does in fact work

    Thanks Again

  5. #5
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    nope didnt work


    still looking for the answer thanks

  6. #6
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    forgot the 0 in the 24 hour clock opps

    Code:
    <?php
    $hourdiff = "8"; // hours diff btwn server and local time
    $time = date("h:i a",time() - ($hourdiff * 3600));
    print ("$time");
    echo "<br />";
    echo "<br />";
    echo "<br />";
    echo "<br />";
    $d=date(H);
    if ($d > 08 && $d < 16)
    echo "<B>Support Online</B>"; 
    else
    echo "<B>Support Offline</B>"; 
    ?>

Bookmarks

Posting Permissions

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