...

View Full Version : World clock?



westmatrix99
03-12-2007, 10:56 AM
Any idea how to make a world clock?
I have some code to play around with(can't remember where I got it from)



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Worldclock</title>
<script language="JavaScript"><!--
function refre****() {
if (!document.images) return;
document.images['image'].src = 'clock.php?' + Math.random();
setTimeout('refre****()',1000); // refresh every 5 secs
}
//--></script>
</head>
<body onLoad=" setTimeout('refre****()',1000)">
<table width="500">
<tr>
<td><img src="clock.php" id="image" /></td>
<td><img src="clock.php" id="image" /></td>
</tr>
<tr>
<td>South Africa </td>
<td>Other country</td>
</tr>
</table>
</body>
</html>
?>

mlseim
03-12-2007, 09:33 PM
Some sources here:

http://www.google.com/search?hl=en&q=java+world+clock&btnG=Google+Search

It's funny how many clocks online have crashed with the new U.S. Daylight Saving Time switch-over.

westmatrix99
03-13-2007, 01:21 PM
Thanks but my code uses GD, PHP and java not just javascript.

Cheers
West

westmatrix99
03-13-2007, 04:34 PM
Forgot to add clock.php code.


<?php
Header("Content-type: image/png");
$time = strftime("%I:%M:%S", time());
$timearray = explode(':',$time);
$hour = (((int)$timearray[0]) * 60) + (int)$timearray[1];
$minute = (int)$timearray[1];
$second = (int)$timearray[2];
if($hour != 0) {
$hourdegree = ((360 / (720 / $hour)) - 90) % 360;
if($hourdegree < 0) { $hourdegree = 360 + $hourdegree; }
} else {
$hourdegree = 270;
}
if($minute != 0) {
$minutedegree = ((360 / (60 / $minute)) - 90) % 360;
if($minutedegree < 0) { $minutedegree = 360 + $minutedegree; }
} else {
$minutedegree = 270;
}
if($second != 0) {
$seconddegree = ((360 / (60 / $second)) - 90) % 360;
if($seconddegree < 0) { $seconddegree = 360 + $seconddegree; }
} else {
$seconddegree = 270;
}
$image = imagecreate(100,100);
$maroon = ImageColorAllocate($image,123,9,60);
$white = ImageColorAllocate($image,255,255,255);
$black = ImageColorAllocate($image,0,0,0);
ImageFilledRectangle($image,0,0,99,99,$white);
ImageFilledEllipse($image,49,49,100,100,$black);
ImageFilledEllipse($image,49,49,95,95,$maroon);
ImageFilledEllipse($image,49,49,75,75,$white);
ImageFilledEllipse($image,49,49,5,5,$maroon);
ImageFilledArc($image,49,49,50,50,$hourdegree-4,$hourdegree+4,
$maroon,IMG_ARC_PIE);
ImageFilledArc($image,49,49,65,65,$minutedegree-3,$minutedegree+3,
$maroon,IMG_ARC_PIE);
ImageFilledArc($image,49,49,70,70,$seconddegree-2,$seconddegree+2,
$black,IMG_ARC_PIE);
ImageColorTransparent($image,$white);
ImageTTFText ($image, 8, 0, 44, 11, $white,
"ConvectionRegular.ttf","12");
ImageTTFText ($image, 8, 0, 89, 53, $white,
"ConvectionRegular.ttf","3");
ImageTTFText ($image, 8, 0, 47, 96, $white,
"ConvectionRegular.ttf","6");
ImageTTFText ($image, 8, 0, 5, 53, $white,
"ConvectionRegular.ttf","9");
imagePNG($image);
imagedestroy($image);
?>


Any idea how to make a world clock?
I have some code to play around with(can't remember where I got it from)



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Worldclock</title>
<script language="JavaScript"><!--
function refre****() {
if (!document.images) return;
document.images['image'].src = 'clock.php?' + Math.random();
setTimeout('refre****()',1000); // refresh every 5 secs
}
//--></script>
</head>
<body onLoad=" setTimeout('refre****()',1000)">
<table width="500">
<tr>
<td><img src="clock.php" id="image" /></td>
<td><img src="clock.php" id="image" /></td>
</tr>
<tr>
<td>South Africa </td>
<td>Other country</td>
</tr>
</table>
</body>
</html>
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum