I'm trying to get the schedule for "current" date and time based on visitor's "timezone" from this XML file:
<programme start="20220120070000 +0000" stop="20220120080251 +0000" channel="33">
<title lang="en">
Hockey Night in Thailand Nov 17 2019_Game_1 Eps 005
</title>
<sub-title lang="en">
Hockey Night in Thailand Nov 17 2019_Game_1 Eps 005
</sub-title>
<desc lang="en">
Encore Presentation of the Siam Hockey League (SHL) from Bangkok Thailand
</desc>
<date>20220120</date>
<category lang="en">Featured</category>
<category lang="en">Airy TV 1</category>
</programme>
So far I have managed to get the full output or just the first 10 lines or "playing now" but I don't know how I could restrict the results for current day, visitor's timezone +10 hours (for example).
All I want is to get the following output 15-20 lines, no more, ignoring the "Filler" also.
PLAYING NOW : Hockey Night in Thailand Rewind Dec_1_2019_Game_1 Ep 011
NEXT:
22.01.21 : 10:37 - 11:03 - Let's_Go_Thailand_Sights_and_Sounds_Ep_010
22.01.21 : 11:03 - 11:06 - ThailandTV_Filler_1F
22.01.21 : 11:06 - 11:35 - Let's_Go_Thailand_Sights_and_Sounds_Bangkok_Ep_011
22.01.21 : 11:35 - 11:38 - ThailandTV_Filler_1H
22.01.21 : 11:38 - 12:05 - Let's_Go_Thailand_Sights_and_Sounds_Ep_012
22.01.21 : 12:05 - 12:55 - Going_Astray_(11_screen_version) ...
Any help will be much appreciated!
Thanks! Ady
Code used:
For first 10 lines
<?php
session_start();
$timezone = $_SESSION['time'];
$line = 0 ;
$xml=simplexml_load_file("https://hls.airy.tv/airytv/33");
echo "<br>";
foreach($xml->programme as $item){
if ($line++ == 10) break;
echo " " .date("y.m.d", strtotime(substr($item["start"], 0, -6)));
echo " : " .date("G:i", strtotime(substr($item["start"], 0, -6)));
echo " - " .date("G:i ", strtotime(substr($item["stop"], 0, -6)));
echo " - ".$item->title;
echo "<br>";
}
?>
Output:
22.01.20 : 7:00 - 8:02 - Hockey Night in Thailand Nov 17 2019_Game_1 Eps 005
22.01.20 : 8:02 - 8:04 - ThailandTV_Filler_1A
22.01.20 : 8:04 - 9:03 - Hockey Night in Thailand Nov 17 2019 Game 2 Eps 006
22.01.20 : 9:03 - 9:04 - ThailandTV_Filler_1B
22.01.20 : 9:04 - 9:33 - Let's_Go_Thailand_Motorcycles,_Mr._Cartoon_Ep_005
22.01.20 : 9:33 - 10:00 - Let's_Go_Thailand_Amazing_Elephants_Ep_006
22.01.20 : 10:00 - 10:03 - ThailandTV_Filler_1F
22.01.20 : 10:03 - 11:03 - Hockey Night in Thailand Nov 21 2019_Game 1 Eps 007
22.01.20 : 11:03 - 11:04 - ThailandTV_Filler_1A
22.01.20 : 11:04 - 12:02 - Hockey Night in Thailand Nov 21 2019 Game 2 Eps 008
For playing NOW
<?php
$channels = array();
foreach ($xml->channel as $c) {
$channels[ $c['id']->__toString() ] = $c->{'display-name'}->__toString();
}
$time = date( "YmdHi" );
$xml=simplexml_load_file("https://hls.airy.tv/airytv/33");
foreach($xml->programme as $item) {
$start = substr( (string)$item["start"], 0, -8);
$end = substr( (string)$item["stop"], 0, -8);
if ($time > $start && $time < $end) {
// echo "Start : " .date("G:i d.m.Y", strtotime($start)) . '<br>';
// echo "End : " .date("G:i d.m.Y", strtotime($end)) . '<br>';
echo "PLAYING NOW : ".$item->title. "<br>";
}
}
?>
Output
PLAYING NOW : Hockey Night in Thailand Rewind Dec_1_2019_Game_1 Ep 011
For FULL SCHEDULE
<?php
session_start();
$timezone = $_SESSION['time'];
$i = 0;
$xml=simplexml_load_file("https://hls.airy.tv/airytv/33");
echo "<br>";
foreach($xml->programme as $item){
echo " " .date("y.m.d", strtotime(substr($item["start"], 0, -6)));
echo " : " .date("G:i", strtotime(substr($item["start"], 0, -6)));
echo " - " .date("G:i ", strtotime(substr($item["stop"], 0, -6)));
echo " - ".$item->title;
echo "<br>";
}
?>
Output
22.01.20 : 7:00 - 8:02 - Hockey Night in Thailand Nov 17 2019_Game_1 Eps 005
22.01.20 : 8:02 - 8:04 - ThailandTV_Filler_1A
22.01.20 : 8:04 - 9:03 - Hockey Night in Thailand Nov 17 2019 Game 2 Eps 006
22.01.20 : 9:03 - 9:04 - ThailandTV_Filler_1B
22.01.20 : 9:04 - 9:33 - Let's_Go_Thailand_Motorcycles,_Mr._Cartoon_Ep_005
22.01.20 : 9:33 - 10:00 - Let's_Go_Thailand_Amazing_Elephants_Ep_006
22.01.20 : 10:00 - 10:03 - ThailandTV_Filler_1F
22.01.20 : 10:03 - 11:03 - Hockey Night in Thailand Nov 21 2019_Game 1 Eps 007
22.01.20 : 11:03 - 11:04 - ThailandTV_Filler_1A
22.01.20 : 11:04 - 12:02 - Hockey Night in Thailand Nov 21 2019 Game 2 Eps 008
22.01.20 : 12:02 - 12:05 - ThailandTV_Filler_1H
22.01.20 : 12:05 - 12:33 - Let's_Go_Thailand_Chiang_Mai._Ep_007
22.01.20 : 12:33 - 12:34 - ThailandTV_Filler_1A
22.01.20 : 12:34 - 13:01 - Let's_Go_Thailand_Amazing_Elephants_Ep_006
22.01.20 : 13:01 - 13:07 - ThailandTV_Filler_1N
... (a very long list)