You can thanks USIS for this mess...
function splitdesc ($desc, $option) {
$data = explode('
', $desc, 2);
if ($option == 'start'||$option == 'finish') {
$months = array(1=>"January",2=>"February",3=>"March",4=>"April",5=>"May",6=>"June",7=>"July",8=>"August",9=>"September",10=>"October",11=>"November",12=>"December");
$separated = explode(' at ', $data[0], 2);
$date_array = explode(" ", substr(trim($separated[0]), 18));
if ($option=="finish") $subtime = 1;
else $subtime = 0;
$time = explode(' until ', $separated[1], 2);
$ampm = explode(" ", $time[$subtime], 2);
$time_array = explode(":", $ampm[0]);
if ($ampm[1] == 'pm') $h24 = 12;
else $h24 = 0;
return mktime(
$time_array[0] + $h24, // Hours, corrected from 12h time
$time_array[1], // Minutes
0, // Seconds
array_search(substr($date_array[3], 0, strlen($date_array[3])-1),$months), // Month, minus the comma and looked up
substr($date_array[1], 0, strlen($date_array[1])-2), // Day, minus ordinal
$date_array[4]); // Year
} else {
return $data[1];
}
}
Spaghetti code at its finest.
Basically I needed to chop up events from
feeds like this into a useful format; complicated when the time/date is given as a string mixed into the description...
Bah! Bloody university!