I want to use the $_GET[] along with the getdate() to pull in the date as query string in the form of: YYYY-mm-dd. If no date is entered, then get the current date. This is what I have done, but I don't have a clue as to if I'm close or not.
if(!isset($_GET['date']))
{
//$date = "2012-09-15";
$date = date('Y-m-d');
}
elseif(DateTime::createFromFormat('Y-m-d', $_GET['date']))
{
//$date = DateTime::createFromFormat('Y-m-d',$_GET['date']);
$date = $_GET['date'];
}
else
{
$date = date('Y-m-d');
}
$calendar = DateTime::createFromFormat('Y-m-d', $date);
//This is something else I was attempting
//if(isset($_GET['date']) ? $_GET['date'] : $date = date('Y-m-d')
//$date = explode("-", $_GET['date']);
//$date = date('Y-m-d');
// Create new DateTime object passing the date as a string.
$calendar = DateTime::createFromFormat('Y-m-d', $date);