Zend - The PHP Company




Date & Time

Add Code


PHP Clock  

Type: code fragment
Added by: prochazka
Entered: 24/11/2000
Last modified: 01/12/2000
Rating: - (fewer than 3 votes)
Views: 18614
View round clock in GIF format.


<?
/*
 * PHP Clock
 * v. 0.9.2
 *
 * 24-11-2000 18.45
 *
 * (C) 2000 prochazka@cernosice.cz
 */

    
Header("Content-type: image/gif");
    
Header("Expires: ".GMDate("D, d M Y H:i:s")." GMT");

    
$th = ((Date(U) % 43200)+3600) / (4320/2*PI());
    
$tm Date(U) % 3600  / (360 /2*PI());
    
$ts Date(U) % 60    / (6   /2*PI());

    
$sirka 100// width
    
$vyska 100// height

    
$stredx $sirka/2//center x
    
$stredy $vyska/2//center y

    
$r min($sirka$vyska)/2-(min($sirka$vyska)/10);

    
$img ImageCreate($sirka,$vyska);
    
$color ImageColorAllocate($img58110165);
    
ImageFill ($img00$color);

    
$color ImageColorAllocate($img255255255);

    
$hx $stredx $r*0.60 sin($th);
    
$hy $stredy $r*0.60 cos($th);
    
$mx $stredx $r sin($tm);
    
$my $stredy $r cos($tm);
    
$sx $stredx $r sin($ts);
    
$sy $stredy $r cos($ts);

    
$colorcopy ImageColorAllocate($img102153204);
    
$colorcopy2ImageColorAllocate($img163193224);

    
ImageString ($img255Date("H:i:s"), $colorcopy);

    for(
$i=0$i<12$i++)
    {
        
$bod $i / (1.2/2*PI());

        
$bodx $stredx + ($r*1.0) * sin($bod);
        
$body $stredy - ($r*1.0) * cos($bod);

        
Imagesetpixel($img$bodx$body$color);
    }

    
ImageLine($img$stredx-2$stredy$hx-2$hy$colorcopy);
    
ImageLine($img$stredx+2$stredy$hx+2$hy$colorcopy);
    
ImageLine($img$stredx-1$stredy$hx-1$hy$colorcopy2);
    
ImageLine($img$stredx  $stredy$hx  $hy$color);
    
ImageLine($img$stredx+1$stredy$hx+1$hy$colorcopy2);

    
ImageLine($img$stredx-1$stredy$mx-1$my$colorcopy);
    
ImageLine($img$stredx+1$stredy$mx+1$my$colorcopy);
    
ImageLine($img$stredx$stredy$mx$my$color);

    
ImageLine($img$stredx$stredy$sx$sy$color);

    
ImageGif($img);
?>


Usage Example


See the example


Rate This Script





Search



This Category All Categories