HOW CAN WE KNOW THE NUMBER OF DAYS BETWEEN TWO GIVEN DATES USING PHP?

Awadhendra Tiwari

Total Post:510

Points:2550
Posted by  Awadhendra Tiwari
PHP 
PHP
 1175  View(s)
Ratings:
Rate this:
  1. Awadhendra Tiwari

    Post:510

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

    We will use following concept to retrive difference between two dates.

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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!