Only 1 thing i would suggest changing..
You have to "refresh" the page for it to see the "time change".
If you can bind it with AJAX that would be a really Good tutorial!
Reloading an image with JavaScript/Image would look a bit choppy. You could set the clock as a background and make the arms CSS classes or IDs. With AJAX/JavaScript you could move them to new locations.
Nice bit of code though!
Instead of giving a path for each number just catenate the string to get a path, like this:
"http://forum.codecall.net/images/" . number . ".jpg"
note: I'm assuming that php uses the . operator for catenation, like perl.
A few things I noticed that might be of an improvement. Rather thanYou can simply doCode:// Get date
$date = date("h:i");
// Brake it from :
$date_slice = explode(":", $date);
// First pair of numbers
$firstpart = $date_slice['0'];
// Second pair of numbers
$secondpart = $date_slice['1'];
// Let's get first number of first pair
$numbers = array();
// Now let's get numbers
$numbers['first_part1'] = substr($firstpart, 0, 1);
$numbers['second_part1'] = substr($firstpart, -1, 2);
$numbers['first_part2'] = substr($secondpart, 0, 1);
$numbers['second_part2'] = substr($secondpart, -1, 2);
Code:$date = date("h:i");
$numbers['first_part1'] = $date[0];
$numbers['second_part1'] = $date[1];
$numbers['first_part2'] = $date[3];
$numbers['second_part2'] = $date[4];
A slightly different approach might be to take advantage of the built in image functions.
image.php
index.phpCode:<?php
$im = imagecreate(100, 30);
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 5, 0, 0, date("h:i"), $textcolor);
header("Content-type: image/png");
imagepng($im);
?>
Code:<img src="image.php" />
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks