Mega Code Archive

 
Categories / Php / Date Time
 

PHP Round Clock - Must have Gif support to use this

<? /* * PHP Clock */ 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($img, 58, 110, 165); ImageFill ($img, 0, 0, $color); $color = ImageColorAllocate($img, 255, 255, 255); $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($img, 102, 153, 204); $colorcopy2= ImageColorAllocate($img, 163, 193, 224); ImageString ($img, 2, 5, 5, Date("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); ?>