How to get number of days between two dates in php?
You can find out the number of days between two dates from your database.
$today= date('d-m-Y'); // get today's date
// here you can also change today's date according to your requirement
// here timestamp value has been retrieved from database
$datetime1 = new DateTime("$timestamp");
$datetime2 = new DateTime("$today");
$difference = $datetime1->diff($datetime2); // compare both dates
$days= 'Difference: '.$difference->days.' days';
// get the days difference in a variable
echo $days; // Print the days where you want to show
// You can also get the difference in year, months
// to get the year difference, use below code
$years= 'Difference: '.$difference->y.' years';
// to get the month difference, use below code
$months= 'Difference: '.$difference->m.' months';
For any technical query and support, you can share your question with us through below comment section. Our technical team always happy to serve you !!
Waiting for your comments