• Hi i have been working on a daily tv guide plugin for my blog.

    see here:
    https://pirrana.co.uk/blog/index.php/vlowe-tv-guide/

    its early in dev yet ??

    i just thorght it would be cool to colour whats on now!

    im not too hot on date/time just wondered if anyone could help me out.

    currently i print the date using
    print $Programme[‘time’];
    that will display something like 4:05pm

    ideas:
    1. if $Programme[‘time’] = time now , color = yellow
    else normal

    2. if $Programme[‘time’] = time now +/- 15mins, color = yellow
    else normal

    3. the holy grail! find the last start time before current time!

    that would be great but no idea how to do it.

    any ideas or solutions?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter vlowe

    (@vlowe)

    please help someone

    a good start would be how to create a variable of the time now in this format 4:05pm

    also

    any ideas on a time range before and after this time by say 15 mins.

    dont want to use $time -5 as that would just be five mins earlier i need it to be between now and then. if u get me

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    It’s hard to say what to do without seeing your code.

    You’ll want to take the time you receive from wherever and convert it to the epoch time. You’ll probably use strtotime() to do this. You should also get the next time value to determine the end of the program. Or maybe you have a length value somewhere? Depends on your input data.

    Then you get the current time with time().

    Then you compare the times, and determine whether the program is on now. If it is, I would have it output a special class on the item, like “program_on_now” or something. Then you can use that in the CSS to change the background color. That way, you can change the background colors without changing the code later.

    Thread Starter vlowe

    (@vlowe)

    cheers guys,

    i have been playing with it last night.

    i can get the date now:
    putenv(“TZ=Europe/London”);
    date(‘h:ia’)

    so i tried.
    $vdate = date(‘h:ia’);

    if ($Programme[‘time’] < $vdate){
    print ‘<font color=”#FF0000″>’.$aProgramme[‘time’].'</font>’;
    }
    else {
    print $aProgramme[‘time’];
    }

    i was trying to show started programmes in red.
    this gave inacurate results.

    probably because of the am/pm??

    i would move to 24hr format but the data i fetch is in 12hr with the am/pm attached ??

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    You cannot directly compare two different dates like that. Those are not times, they are *strings*.

    What you have to do is convert both datetimes into a *number*. time() will give you the current time in the form of a number, and you can use strtotime() to convert the Programme[time] into a number as well.

    Once you have them both as *numbers*, then you can compare them and get accurate results. Comparing them as strings will give you the inaccurate results.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘New TV guide Plugin – Syntax help pls.’ is closed to new replies.