Basic PHP Programming Question: Download PHP PDF

How can we know the number of days between two given dates using PHP?

Tweet Share WhatsApp

Answer:

Simple arithmetic:

$date1 = date('Y-m-d');
$date2 = '2006-07-01';
$days = (strtotime() - strtotime()) / (60 * 60 * 24);
echo "Number of days since '2006-07-01': $days";

Download PHP PDF Read All 139 PHP Questions
Previous QuestionNext Question
What is meant by PEAR in php?How can we repair a MySQL table?