PHP Developer Question:

Download Job Interview Questions and Answers PDF

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

PHP Developer Interview Question
PHP Developer Interview Question

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 Developer Interview Questions And Answers PDF

Previous QuestionNext Question
Where PHP configuration settings stored?How to repair MySQL table?