Jump to content

PHP Clock


wonderbreadz

Recommended Posts

Here's what I've got so far:

<?
//echo date("l, F d")."<br />"; --- Saturday, September 27
//echo date("h:i"); //--- 05:24
date_default_timezone_set('Australia/Adelaide');

function clockHrs($timevar,$minuvar){
if(date("h") == $timevar){
echo "<font color='red'>H</font>";
}else{
        echo $timevar;
}
}
?>

<title>Robs PHP Clock</title>
<body>
                      <? clockHrs(12) ?><br />
               <? clockHrs(11) ?>            <? clockHrs(1) ?><br />
          <? clockHrs(10) ?>                      <? clockHrs(2) ?><br />
     <? clockHrs(9) ?>                                <? clockHrs(3) ?><br />
          <? clockHrs( ?>                      <? clockHrs(4) ?><br />
               <? clockHrs(7) ?>            <? clockHrs(5) ?><br />
                      <? clockHrs(6) ?><br />
<br />
<br />
x = Minutes -- <font color='red'>H</font> = Hour
</body>


 

Basically, I've got the hours working.

I'm stuck on getting the minutes to work properly though.

I've tried using IF's for each of them but it got VERY messy and wasn't too efficient either.

 

I want it to put "<font color='red'>X</font>" on the number closest to the minute.

EG, if the time was 2:13 it would be on the 3 (3rd one in)

 

Sort-of understand?

Give me a shout if you dont, I'm not always the best at explaining stuff =x

Link to comment
https://forums.phpfreaks.com/topic/126264-php-clock/
Share on other sites

  • 2 weeks later...

Without seeing the rest of your code, it's hard to judge what will happen.  Consider an alternative:

 

You have 1 main static (or a few, depending on time of day) image of a clock face (like you are trying to draw), 12->11  in a circle.

 

Now, you want to display a line for what hour it currently is... You could make a sprite image of the 12 angles that the line would appear(yes i know some angles are repeated), and have php scroll to that image in the sprite and superimpose it over the clock face using appropriate CSS.

 

The same concept can be applied for minutes, seconds.., but try not to crowd your clock too much.

 

Sorry that this isn't what you're asking... even using a monospaced font, the change btwn single and double digit numbers kinda makes the design weird when it changes.

Link to comment
https://forums.phpfreaks.com/topic/126264-php-clock/#findComment-659594
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.