I have the following query in my page ?filterFrom=11%2F01%2F2014&filterTo=11%2F25%2F2014
Now I have the following code
// Get Start
if(isset($_GET['filterFrom']) && !empty($_GET['filterFrom'])) {
$startDate = new DateTime(str_replace('/', '-', $_GET['filterFrom']));
$sqlArray[":searchFrom"] = $startDate->format('Y-m-d').' 00:00:00';
}
// Get End
if(isset($_GET['filterTo']) && !empty($_GET['filterTo'])) {
$endDate = new DateTime(str_replace('/', '-', $_GET['filterTo']));
$sqlArray[":searchTo"] = $endDate->format('Y-m-d').' 23:59:59';
}
The "Get Start" part of the script works fine, but when it gets to "Get End", I get the following error:
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (11-25-2014) at position 0 (1): Unexpected character'
I have this exact same script on 6 other pages and don't have any issues! Does anyone know what could be going wrong??