Creating a gif image or flash image that changes depending on time

Discussion in 'Web Design and Development' started by DaveChappers, Jan 14, 2009.

  1. DaveChappers macrumors newbie

    Joined:
    Jan 10, 2009
    #1
    Hey there, im trying to create a logo image that will change at a certain time for a radio show I help out on.
    Basically when the show is on air say between 7 and 9 pm, I want the logo to say on air. And at other times to stay off air.
    Not sure if there is any other way to do this, but im a bit of a newbie at web stuff.

    Thanks for any help you can give

    Dave
     
  2. jrrdnx macrumors member

    jrrdnx

    Joined:
    Nov 13, 2008
    Location:
    Indiana
    #2
    Do you know if your site uses PHP?

    If so, you can easily use PHP to figure out the time of day and print the correct image tag.

    PHP:
    $time date('G'); // 24-hour format without leading zeroes

    if($time >= && $time <= 21) {
         print 
    "<img src='{filepath of ON-AIR image}'>";
    } else {
         print 
    "<img src='{filepath of OFF-AIR image}'>";
    }
    I'm assuming the 7 in your post is AM, if not change that number to 19.
     
  3. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #3
    If PHP is not an option you could use JavaScript to change out the image for that time period, but will only work for visitors who have it enabled. PHP (or any other server side language) would be the preferred method though.
     
  4. DaveChappers thread starter macrumors newbie

    Joined:
    Jan 10, 2009
    #4
    Ah this looks like it will work :) Thanks muchly!

    However I know have a more tricky task. Gotta get it to do the same thing on the radio's myspace page.

    Is that even possible, I know Myspace disables most javascript so thats prob out.

    Any ideas guys
     
  5. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #5
    A thought: from MySpace you setup an image tag like,
    HTML:
    <img alt="my cool pic" src="myotherwebsite.com/images/cool_pic.php" />
    Then in your PHP file named cool_pic.php it would have parts consisting of,
    PHP:
    header('Content-Type: image/gif');
    // Place the previous code here, except just get the image file path and put it in a variable
    //  here named $img_path
    echo file_get_contents($img_path);
    Disclaimer: I haven't tried this exact code so you may need to tweak it beyond what's mentioned.
     

Share This Page