I have two tables in Database and both fields has the datetime columns I want to extract only the date part form the columns and compare it. MySql give the YYYY-MM-DD HH:MM:SS format and I can't compare because of the time difference even though the date is same.
SELECT * FROM table1;
SELECT * FROM table2;
table1.date == table2.date
How can I only compare date excluding time in PHP?
You can get date+time($table1_date) from Mysql and exclude time in PHP like this:
$full_date = strtotime($table1_date);
$date_only = date("d-m-Y", $full_date);
You can use MySQL's DATE_FORMAT() function to format the date, e.g.:
SELECT DATE_FORMAT(date,'%Y-%m-%d') FROM table;
Once you get the dates from both the tables, you can show/compare them in php.