Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 27

Thread: Display different image each hour of the day (based on server time)

  1. #11
    Join Date
    Aug 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi there, im using this php script and i want to add minutes on the script but i have a problem when the radio programs last more than an hour the script just doesnt show anything after that minute comes.

    Code:
    <?php
    $hora = date('G'); // Horas de 0 a 23
    $dia = date('w'); // Dias 0 (Domingo) a 6 (Sabado)
    $minuto = date('i'); // Minutos de 00 a 59
    
    $hora = $hora+1;
    $minuto = $minuto+21;
    
    // MARTES
    if ($dia == 2 && $hora >= 0 && $hora < 4) $img = 'images/yaco.gif';
    else if ($dia == 2 && $hora >= 4 && $hora < 8) $img = 'images/nancy.gif';
    else if ($dia == 2 && $hora >= 8 && $hora < 12) $img = 'images/lucas.gif';
    else if ($dia == 2 && $hora >= 12 && $hora < 13) $img = 'images/juan.gif';
    else if ($dia == 2 && $hora >= 13 && $hora < 15) $img = 'images/henoch.gif';
    else if ($dia == 2 && $hora >= 15 && $hora < 17) $img = 'images/gustavo.gif';
    else if ($dia == 2 && $hora >= 17 && $hora <= 21 && $minuto <= 44) $img = 'images/edmundo.gif';
    ?>
    
    <html>
    <head></head>
    <body>
    	
    Estas escuchando a...
    
    <br><br>
    
    <img src="<?php echo $img; ?>">
    
    </body>
    </html>
    can you guys help me please? thanks in advance!

  2. #12
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Bringing back the dead...

    Hi,

    This post is old but...

    I just came across this script and it's almost exactly what I need, but I'm also interested in adding minutes as my schedule changes on the mid point of some hours.

    If anyone can help, I would appreciate it greatly. I would even pay you a bit for you time.

    Thanks.

  3. #13
    Join Date
    Sep 2011
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    would it be possible for this code to be made in to html or css? if so would someone please help me to do it as I dont know how.

  4. #14
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    HTML and CSS don't allow for conditional ("if") statements. No. You need Javascript, or a serverside programming language like PHP, ASP, CGI, etc.
    (Of course any of those can be combined with HTML and CSS as needed to create the desired look.)
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #15
    Join Date
    Sep 2011
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hello thanks for your reply,

    the problem I have is I can not upload PHP to my host, but JS etc I can, would it be possible for you to help me make this into a JS code by any chance?

  6. #16
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I should clarify something: you can do this in Javascript, but you cannot base it on server time. It will be based on the user's time on their computer (even if it is wrong or in a different location). You might be able to use Javascript to make it relative to the right timezone (adjust based on the current timezone) if that information is available. I'm not sure.

    But if you google "change image every hour javascript" you will find some information. Please do a search first.

    If your specific question is about the server time, then, no, you must have a serverside language like PHP available. You can do everything else in Javascript, but not the server time.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. #17
    Join Date
    Jan 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need exactly the same but....

    Quote Originally Posted by yrrot View Post
    Hi Everyone,
    Thanks for all your help on this one. I succesfully got this working on the new site I'm creating. I needed to display a different image for each radio host at different points throughout the day, each day of the week. I also had to include a 2 hour offset from the server's time to match my time zone. Here's what my final code looks like.

    Hopfully this is helpfule to others looking to do the same thing.

    Regards,
    Torry

    PHP Code:
    <?php
    $h 
    date('G'); //set variable $h to the hour of the day
    $d date('w'); //set variable $d to the day of the week.
    $year date('Y'); //set variable $year to the current year
    //G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.
    // Adjust 2 hour offset for MST below.
    $h $h-2;

    // MONDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'img/hosts/petem.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/angelaa.jpg';
    else if (
    $d == && $h >= && $h 12$img 'img/hosts/shonw.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'img/hosts/pottsie.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'img/hosts/mikef.jpg';
    else if (
    $d == && $h >= 15 && $h 19$img 'img/hosts/lizzy.jpg';
    else if (
    $d == && $h >= 19$img 'img/hosts/danic.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/danic.jpg';

    // TUESDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'img/hosts/petem.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/angelaa.jpg';
    else if (
    $d == && $h >= && $h 12$img 'img/hosts/shonw.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'img/hosts/pottsie.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'img/hosts/mikef.jpg';
    else if (
    $d == && $h >= 15 && $h 17$img 'img/hosts/lizzy.jpg';
    else if (
    $d == && $h >= 17 && $h 20$img 'img/hosts/westmar.jpg';
    else if (
    $d == && $h >= 20$img 'img/hosts/danic.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/danic.jpg';

    // WEDNESDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'img/hosts/petem.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/angelaa.jpg';
    else if (
    $d == && $h >= && $h 12$img 'img/hosts/shonw.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'img/hosts/pottsie.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'img/hosts/mikef.jpg';
    else if (
    $d == && $h >= 15 && $h 19$img 'img/hosts/lizzy.jpg';
    else if (
    $d == && $h >= 19$img 'img/hosts/danic.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/danic.jpg';

    // THURSDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'img/hosts/petem.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/angelaa.jpg';
    else if (
    $d == && $h >= && $h 12$img 'img/hosts/shonw.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'img/hosts/pottsie.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'img/hosts/mikef.jpg';
    else if (
    $d == && $h >= 15 && $h 19$img 'img/hosts/lizzy.jpg';
    else if (
    $d == && $h >= 19$img 'img/hosts/danic.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/danic.jpg';

    // FRIDAY SCHEDULE
    if ($d == && $h >= && $h 4$img 'img/hosts/petem.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/angelaa.jpg';
    else if (
    $d == && $h >= && $h 10$img 'img/hosts/shonw.jpg';
    else if (
    $d == && $h >= 10 && $h 12$img 'img/hosts/patm.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'img/hosts/pottsie.jpg';
    else if (
    $d == && $h >= 13 && $h 15$img 'img/hosts/edp.jpg';
    else if (
    $d == && $h >= 15 && $h 18$img 'img/hosts/lizzy.jpg';
    else if (
    $d == && $h >= 18 && $h 20$img 'img/hosts/jeremyb.jpg';
    else if (
    $d == && $h >= 20 && $h 22$img 'img/hosts/exfyl.jpg';
    else if (
    $d == && $h >= 22$img 'img/hosts/stickyb.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/stickyb.jpg';

    // SATURDAY SCHEDULE
    else if ($d == && $h >= && $h 4$img 'img/hosts/techtronic.jpg';
    else if (
    $d == && $h >= && $h 5$img 'img/hosts/pmw.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/geoffh.jpg';
    else if (
    $d == && $h >= && $h 9$img 'img/hosts/tomf.jpg';
    else if (
    $d == && $h >= && $h 10$img 'img/hosts/jimmyj.jpg';
    else if (
    $d == && $h >= 10 && $h 11$img 'img/hosts/jasonr.jpg';
    else if (
    $d == && $h >= 11 && $h 12$img 'img/hosts/hollyk.jpg';
    else if (
    $d == && $h >= 12 && $h 13$img 'img/hosts/tomt.jpg';
    else if (
    $d == && $h >= 13 && $h 14$img 'img/hosts/seanf.jpg';
    else if (
    $d == && $h >= 14 && $h 15$img 'img/hosts/nutmeg.jpg';
    else if (
    $d == && $h >= 15 && $h 17$img 'img/hosts/aaron_jenny.jpg';
    else if (
    $d == && $h >= 17 && $h 19$img 'img/hosts/rayg_adrians.jpg';
    else if (
    $d == && $h >= 19 && $h 22$img 'img/hosts/mattb.jpg';
    else if (
    $d == && $h >= 22$img 'img/hosts/hairballj.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/hairballj.jpg';

    // SATURDAY SCHEDULE
    else if ($d == && $h >= && $h 2$img 'img/hosts/darrelm.jpg';
    else if (
    $d == && $h >= && $h 4$img 'img/hosts/techtronic.jpg';
    else if (
    $d == && $h >= && $h 5$img 'img/hosts/bigjon.jpg';
    else if (
    $d == && $h >= && $h 6$img 'img/hosts/joebear.jpg';
    else if (
    $d == && $h >= && $h 8$img 'img/hosts/russh.jpg';
    else if (
    $d == && $h >= && $h 9$img 'img/hosts/ronk.jpg';
    else if (
    $d == && $h >= && $h 10$img 'img/hosts/rockpoint.jpg';
    else if (
    $d == && $h >= 10 && $h 11$img 'img/hosts/churchatqc.jpg';
    else if (
    $d == && $h >= 11 && $h 12$img 'img/hosts/desertcf.jpg';
    else if (
    $d == && $h >= 12 && $h 16$img 'img/hosts/kristenm.jpg';
    else if (
    $d == && $h >= 16 && $h 17$img 'img/hosts/cdogg.jpg';
    else if (
    $d == && $h >= 17 && $h 18$img 'img/hosts/snarf_daff.jpg';
    else if (
    $d == && $h >= 18 && $h 19$img 'img/hosts/sonicsociety.jpg';
    else if (
    $d == && $h >= 19 && $h 21$img 'img/hosts/jscott.jpg';
    else if (
    $d == && $h >= 21$img 'img/hosts/ghostlytalk.jpg';
    else if (
    $d == && $h 0$img 'img/hosts/ghostlytalk.jpg';
    ?>
    this covers what i would like it to do but im stuck on how to make it more dynamic?
    id like it to run via mysql so that a form to edit all its details is possible on another page..
    so i can select what dj at what time is playing.. or add another dj to the schedule

    can any one please help?

  8. #18
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    2,025
    Thanks
    16
    Thanked 315 Times in 313 Posts
    Blog Entries
    13

    Default

    Do you have much experience with php/MySQL?

    If you have the basis for your HTML form, and have some experience with php/MySQL then this might be something that somebody here can guide you on.

    However, if you have no experience and require somebody to code this for you as a custom application, it will probably need to be taken to the paid work requests forum : http://www.dynamicdrive.com/forums/f...-Work-Requests
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  9. #19
    Join Date
    Aug 2013
    Location
    Rio Maior, Portugal
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi guys,

    I was searching for a code to switch an image at certain interval of time using hour + minutes.

    This code is for a radio so I need to change the image of each host at each hour+minute.

    ie: 7.30 - 7.45 or 8.00 - 10.30

    Can you guys help me on this?

    This is the code i'm using:

    Code:
    <?php
    $h = date('G'); //set variable $h to the hour of the day.
    $m = date('i'); //set variable $m to the min of the hour.
    $d = date('w'); //set variable $d to the day of the week.
    $year = date('Y'); //set variable $year to the current year
    //G is the date key for hours in 24 format (not 12), with no leading 0s, like 02.
    // Adjust 2 hour offset for MST below.
    $h = $h;
    
    // MONDAY SCHEDULE
    if ($d == 1 && $h >= 0 && $h < 4) $img = 'img/hosts/petem.jpg';
    else if ($d == 1 && $h >= 4 && $h < 8) $img = 'img/hosts/angelaa.jpg';
    else if ($d == 1 && $h >= 8 && $h < 12) $img = 'img/hosts/shonw.jpg';
    else if ($d == 1 && $h >= 12 && $h < 13) $img = 'img/hosts/pottsie.jpg';
    else if ($d == 1 && $h >= 13 && $h < 15) $img = 'img/hosts/mikef.jpg';
    else if ($d == 1 && $h >= 15 && $h < 19) $img = 'img/hosts/lizzy.jpg';
    else if ($d == 1 && $h >= 19) $img = 'img/hosts/danic.jpg';
    else if ($d == 2 && $h < 0) $img = 'img/hosts/danic.jpg';
    
    // TUESDAY SCHEDULE
    if ($d == 2 && $h >= 0 && $h < 4) $img = 'img/hosts/petem.jpg';
    else if ($d == 2 && $h >= 4 && $h < 8) $img = 'img/hosts/angelaa.jpg';
    else if ($d == 2 && $h >= 8 && $h < 12) $img = 'img/hosts/shonw.jpg';
    else if ($d == 2 && $h >= 12 && $h < 13) $img = 'img/hosts/pottsie.jpg';
    else if ($d == 2 && $h >= 13 && $h < 15) $img = 'img/hosts/mikef.jpg';
    else if ($d == 2 && $h >= 15 && $h < 17) $img = 'img/hosts/lizzy.jpg';
    else if ($d == 2 && $h >= 17 && $h < 20) $img = 'img/hosts/westmar.jpg';
    else if ($d == 2 && $h >= 20) $img = 'img/hosts/danic.jpg';
    else if ($d == 3 && $h < 0) $img = 'img/hosts/danic.jpg';
    
    // WEDNESDAY SCHEDULE
    if ($d == 3 && $h >= 0 && $h < 4) $img = 'img/hosts/petem.jpg';
    else if ($d == 3 && $h >= 4 && $h < 8) $img = 'img/hosts/angelaa.jpg';
    else if ($d == 3 && $h >= 8 && $h < 12) $img = 'img/hosts/shonw.jpg';
    else if ($d == 3 && $h >= 12 && $h < 13) $img = 'img/hosts/pottsie.jpg';
    else if ($d == 3 && $h >= 13 && $h < 15) $img = 'img/hosts/mikef.jpg';
    else if ($d == 3 && $h >= 15 && $h < 19) $img = 'img/hosts/lizzy.jpg';
    else if ($d == 3 && $h >= 19) $img = 'img/hosts/danic.jpg';
    else if ($d == 4 && $h < 0) $img = 'img/hosts/danic.jpg';
    
    // THURSDAY SCHEDULE
    if ($d == 4 && $h >= 0 && $h < 4) $img = 'img/hosts/petem.jpg';
    else if ($d == 4 && $h >= 4 && $h < 8) $img = 'img/hosts/angelaa.jpg';
    else if ($d == 4 && $h >= 8 && $h < 12) $img = 'img/hosts/shonw.jpg';
    else if ($d == 4 && $h >= 12 && $h < 13) $img = 'img/hosts/pottsie.jpg';
    else if ($d == 4 && $h >= 13 && $h < 15) $img = 'img/hosts/mikef.jpg';
    else if ($d == 4 && $h >= 15 && $h < 19) $img = 'img/hosts/lizzy.jpg';
    else if ($d == 4 && $h >= 19) $img = 'img/hosts/danic.jpg';
    else if ($d == 5 && $h < 0) $img = 'img/hosts/danic.jpg';
    
    // FRIDAY SCHEDULE
    if ($d == 5 && $h >= 0 && $h < 4) $img = 'img/hosts/petem.jpg';
    else if ($d == 5 && $h >= 4 && $h < 8) $img = 'img/hosts/angelaa.jpg';
    else if ($d == 5 && $h >= 8 && $h < 10) $img = 'img/hosts/shonw.jpg';
    else if ($d == 5 && $h >= 10 && $h < 12) $img = 'img/hosts/patm.jpg';
    else if ($d == 5 && $h >= 12 && $h < 13) $img = 'img/hosts/pottsie.jpg';
    else if ($d == 5 && $h >= 13 && $h < 15) $img = 'img/hosts/edp.jpg';
    else if ($d == 5 && $h >= 15 && $h < 18) $img = 'img/hosts/lizzy.jpg';
    else if ($d == 5 && $h >= 18 && $h < 20) $img = 'img/hosts/jeremyb.jpg';
    else if ($d == 5 && $h >= 20 && $h < 22) $img = 'img/hosts/exfyl.jpg';
    else if ($d == 5 && $h >= 22) $img = 'img/hosts/stickyb.jpg';
    else if ($d == 6 && $h < 0) $img = 'img/hosts/stickyb.jpg';
    
    // SATURDAY SCHEDULE
    else if ($d == 6 && $h >= 4 && $h < 6) $img = 'images/horario/pmw.jpg';
    else if ($d == 6 && $h >= 6 && $h < 7) $img = 'images/horario/geoffh.jpg';
    else if ($d == 6 && $h >= 7 && $h < 7) $img = 'images/horario/tomf.jpg';
    else if ($d == 6 && $h >= 7 && $h < 7) $img = 'images/horario/tomf.jpg';
    else if ($d == 6 && $h >= 7 && $h < 9) $img = 'images/horario/jimmyj.jpg';
    else if ($d == 6 && $h >= 9 && $h < 11) $img = 'images/horario/jasonr.jpg';
    else if ($d == 6 && $h >= 11 && $h < 13) $img = 'images/horario/hollyk.jpg';
    else if ($d == 6 && $h >= 13 && $h < 14) $img = 'images/horario/hollyk.png';
    else if ($d == 6 && $h >= 14 && $h < 17) $img = 'images/horario/hollyk.png';
    else if ($d == 6 && $h >= 17 && $h < 23) { $img = 'images/horario/byron.png'; $locutor = 'Byron'; $hora = '5:00 PM - 11:00 PM'; $text = 'ELECTRONIC MUSIC RADIO SHOW'; if(mb_strlen($text)>13) { $text=mb_substr($text, 0, 13); $text.='...'; } } 
    else if ($d == 6 && $h >= 23) $img = 'images/horario/hairballj.jpg';
    else if ($d == 0 && $h < 0) $img = 'images/horario/hairballj.jpg';
    
    // SATURDAY SCHEDULE
    else if ($d == 0 && $h >= 0 && $h < 2) $img = 'img/hosts/darrelm.jpg';
    else if ($d == 0 && $h >= 2 && $h < 4) $img = 'img/hosts/techtronic.jpg';
    else if ($d == 0 && $h >= 4 && $h < 5) $img = 'img/hosts/bigjon.jpg';
    else if ($d == 0 && $h >= 5 && $h < 6) $img = 'img/hosts/joebear.jpg';
    else if ($d == 0 && $h >= 6 && $h < 8) $img = 'img/hosts/russh.jpg';
    else if ($d == 0 && $h >= 8 && $h < 9) $img = 'img/hosts/ronk.jpg';
    else if ($d == 0 && $h >= 9 && $h < 10) $img = 'img/hosts/rockpoint.jpg';
    else if ($d == 0 && $h >= 10 && $h < 11) $img = 'img/hosts/churchatqc.jpg';
    else if ($d == 0 && $h >= 11 && $h < 12) $img = 'img/hosts/desertcf.jpg';
    else if ($d == 0 && $h >= 12 && $h < 16) $img = 'img/hosts/kristenm.jpg';
    else if ($d == 0 && $h >= 16 && $h < 17) $img = 'img/hosts/cdogg.jpg';
    else if ($d == 0 && $h >= 17 && $h < 18) $img = 'img/hosts/snarf_daff.jpg';
    else if ($d == 0 && $h >= 18 && $h < 19) $img = 'img/hosts/sonicsociety.jpg';
    else if ($d == 0 && $h >= 19 && $h < 21) $img = 'img/hosts/jscott.jpg';
    else if ($d == 0 && $h >= 21) $img = 'img/hosts/ghostlytalk.jpg';
    else if ($d == 1 && $h < 0) $img = 'img/hosts/ghostlytalk.jpg';
    
    echo'<div style="float: left; width: 90px"><img src="'.$img.'" height="80px" width="80px" style="border: 1px solid green" /></div><div style="float: left; width: 141px; height: 80px; margin-top: 10px; color: #FFFFFF; font-family: Tahoma; font-size: 15px;">'.$text.' <br \>'.$hora.'<br \> Con: '.$locutor.'</div>';
    ?>
    This is the code. Not finished, I copied from last posts. Works fine just with hours but I wanna add minutes the code. I already put this $m = date('i'); //set variable $m to the min of the hour. at the beginning of the code, but now I don't know how to put it running.

    Thanks in advance.
    Last edited by hornyst; 08-04-2013 at 12:07 PM.

  10. #20
    Join Date
    Aug 2013
    Location
    Rio Maior, Portugal
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default hey

    Quote Originally Posted by Beverleyh View Post
    Beverleyh
    Can you help me?

Bookmarks

Posting Permissions

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