PDA

View Full Version : Clock with Text



CodeRed
12-19-2007, 08:59 AM
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?



<?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

SawnDiddle
12-19-2007, 05:38 PM
<?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.

CodeRed
12-19-2007, 06:54 PM
thank you will do

CodeRed
12-19-2007, 07:10 PM
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


<?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

CodeRed
12-20-2007, 07:25 AM
nope didnt work


still looking for the answer thanks

CodeRed
12-20-2007, 07:35 AM
forgot the 0 in the 24 hour clock opps


<?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>";
?>