In mysql db I've a timestamp field (dateexp) defined in my t1 table. with a query I consider only format Y-m-d of timestamp to find records. Use curdate() instead of now()
SELECT * FROM t1 WHERE dateexp < currdate()
I would like to do the same thing with php using DateTime class for find a number of days until a date but I can't understand how I could do it comparing only the Y-m-d format.
I tried in this way but I use Y-m-d H:i:s format.
$row['dateexp'] = "2013-11-10 12:00:00";
$d1 = new DateTime();
$d2 = new DateTime($row['dateexp']);
$interval = $d1->diff($d2);
$days = $interval->format('%r%a');
How could I do this for comparing only Y-m-d? I tried with DateTime::createFromFormat but probably in wrong way..
Thanks