I’m using PHP to output data from an XML file, specifically the date, which outputs as “20101110.”
Can I use PHP to change this to November 10, 2011? If so, how?
Here’s my page and code:
$file = 'http://www.gostanford.com/data/xml/events/m-baskbl/2010/index.xml';
$xml = simplexml_load_file($file);
foreach($xml as $event_date){
if(!empty($event_date->event['vn']) && !empty($event_date->event['hn']) && !empty($event_date->event['vs']) && !empty($event_date->event['hs']))
{
echo '<li>';
echo '<h3>', $event_date->event['vn'], ' vs ', $event_date->event['hn'], '</h3>';
echo '<p><strong>', $event_date->event['vs'], ' - ', $event_date->event['hs'], '</strong></p>';
echo '<p>', $event_date['date'], '</p>';
echo '<p>', $event_date->event['local_time'], '</p>';
echo '</li>';
}
}
Thanks for your help!
You can use the
date()function, in combination with thestrtotime()function: