Jump to content

PHP Image rotation based on time - minutes


frquency

Recommended Posts

Hello,

I am wondering if anyone can help me here, im looking for some info on where to start with this:

 

I would like to know how I can display a different image based on the time of day perticulary minutes.

 

for example user visits page at 12:02 and gets images "1202.jpg" but if visits at "12:32" they will get the image "1232.jpg"

 

I have seen this done to display radio station DJ's but this was by the hour.

 

Thanks

I can see this being done with 3 images.

1) Blank clock face

2) Hour hand (everything else transparent)

3) Minute hand. (everything else transparent)

 

Then its just a matter of using the GD image library and rotating the hour and minute images to the correct time.

I would like to know how I can display a different image based on the time of day perticulary minutes.

for example user visits page at 12:02 and gets images "1202.jpg" but if visits at "12:32" they will get the image "1232.jpg"

Thats how I took this statement...seems like a clock to me?

What you are looking for is a combination of php/java/html.

Add

<META HTTP-EQUIV="refresh" CONTENT="15">

 

inside the <head></head> and then add a script in either php or java, whatever flavor you like, to get a timestamp, and run it thru a switch().  Or you can have just a random image from an array loaded.

 

something like:

<?php

$Picture_array = array("image1.jpg","image2.jpg","image3.jpg","image4.jpg");

$Randomnumber= rand(1,4);
$picture = $Picture_array[$Randomnumber];

?>
<html>
<head>
<meta http-eqiv="refresh" content = "60" >
</head>
<body>
<image src="<?php echo $picture; ?>" width=180 height=180>
</body>
</html>

 

What you are looking for is a combination of php/java/html.

 

Java is not javascript. They are very different languages.

 

<META HTTP-EQUIV="refresh" CONTENT="15">

 

This isn't a good way to do refreshes - search engines don't like it. The preferred method is:

 

header ('Refresh: 3; url=index.html');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.