I'm using PHP to get XML from an API (Say that 3 times fast). I'm getting all of the correct strings returned from all of the data. The problem comes when I try to reformat the time string with the following two methods:
$dataset = $xmlDoc->getElementsByTagName( "Class" );
foreach( $dataset as $row ) {
$xmlStartTimes = $row->getElementsByTagName( "StartTime" );
$xmlStartTime = $xmlStartTimes->item(0)->nodeValue;
echo $xmlStartTime; // Gives eg. 12/30/1899 6:15:00 PM
// Convert Time to 24H
// Attempt 1:
$cleanStartTime = preg_match('^12/30/1899 (0[1-9]|1[0-2]):(0[1-9]|[1-5][0-9]):([00]) (AM|PM|pm|am)$', $xmlStartTime, $matches);
print_r($matches); // Gives empty array
// Attempt 2:
$cleanStartTime = date("H:i", strtotime("$xmlStartTime"));
echo $cleanStartTime // Gives 1:00
}
Thanks for taking a look.