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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.