Day of the month can be collected from the date and time field by using the function day(). This will return day in number format and we can apply calculation to this. Note that this will not take care of month and year, for example the difference in days between 12th July 04 and 14th July 05 is two days only.
require 'config.php'; // Database connection string
$query='SELECT DAY(CURDATE()- interval 1 day) as YesterDay, DAY(CURDATE()) as Today, DAY(CURDATE()+ interval 1 Day) as Tomorrow';
// Change the above Query part to get different results //
$row = $count->fetch(PDO::FETCH_OBJ);
<table class='table table-striped'>
The basic query for MySQL table is here
SELECT day(dt2) FROM `dt_tb`
This will collect the day part from the field
Difference in Day
The sql query is modified to display all the columns with the days and their difference for easy comparison. Here is the query used.
SELECT DAY(CURDATE()- interval 1 day) as YesterDay, DAY(CURDATE()) as Today, DAY(CURDATE()+ interval 1 Day) as Tomorrow='SELECT dt,dt2,day(dt) as day1,day(dt2)as day2,(day( dt2 ) - day( dt )) as difference FROM `dt_tb`';