Timer

Permalink
I am designing a website for a radio station, is there anyway i get get images to change at a specific time? eg. Chart Show photo to show up at 4:00?

Please help!!

 
jvansanten replied on at Permalink Reply
The simplest approach to this is to write PHP code that will display the desired image during the proper time period. When someone accesses the page in that time period, the desired image will display. However, the image will not be changed if the page is launched in one period and is viewed into the next.

To do this, you'll need to play with the PHP UNIX timestamp function time() which returns the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)..

To get the hour of the day in 24 hour format:

$hour_of_day = $secs / 3600 % 24; // % is the mod operator which gives the integer remainder of a division.

In your markup, have logic like this:

<?php
if ($hour_of_day == 16) {
    echo '<img src = ....>';
    }
elseif ....
?>


or, a switch if more appropriate.