I am trying to pull the weather from the current date from a weather xml file (http://www.yr.no/place/Ireland/Leinster/Dublin/forecast.xml). This xml file splits the weather from each date according to time (00:00-06:00, 06:00-12:00, etc).
So far I have been able to pull out the details I need for all weather for all dates using this code:
$urlweather = ("http://www.yr.no/place/Ireland/Leinster/Dublin/forecast.xml");
$dublin_weather = simplexml_load_file($urlweather);
echo "<table id='weather'>
<tr>
<th>Temperature</th>
<th>Time / Date</th>
<th>Forecast</th>
</tr>";
foreach ($dublin_weather->forecast->tabular->time as $liveweather){
echo ("
<tr>
<td>" .$liveweather->temperature["value"]." °C ". "</td>
<td>" .date_format(date_create($liveweather["from"]), "H:i") .
" - " .date_format(date_create($liveweather["to"]), "H:i"). " / " .date_format(date_create($liveweather["from"]), "d-m-y"). "</td>
<td>" .$liveweather->symbol["name"]."</td>
</tr>");
//}
}
echo "</table";
I would like to be able to only output the weather for the current date so that the weather gets updated every day based on that days date, but cannot seem to figure it out.
Any help would be appreciated.