Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: World clock?

  1. #1
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts

    World clock?

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

    PHP Code:
    <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>
    ?> 
    Thanks for you support!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,468
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Some sources here:

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

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

  • #3
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Thanks but my code uses GD, PHP and java not just javascript.

    Cheers
    West
    Thanks for you support!

  • #4
    Regular Coder westmatrix99's Avatar
    Join Date
    Dec 2006
    Location
    South Africa
    Posts
    307
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Forgot to add clock.php code.

    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 ($image804411$white
    "ConvectionRegular.ttf","12");
    ImageTTFText ($image808953$white
    "ConvectionRegular.ttf","3");
    ImageTTFText ($image804796$white
    "ConvectionRegular.ttf","6");
    ImageTTFText ($image80553$white,
    "ConvectionRegular.ttf","9");
    imagePNG($image);
    imagedestroy($image);
    ?>
    Quote Originally Posted by westmatrix99 View Post
    Any idea how to make a world clock?
    I have some code to play around with(can't remember where I got it from)

    PHP Code:
    <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>
    ?> 
    Thanks for you support!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •