how to compare two dates and how to show the availabilty for the particular date?

You should checkout the DateTime class.

Example:

<?php
$date_1 = new DateTime;
$date_2 = new DateTime;

$date_1->setDate(2015, 02, 01);
$date_1->setTime(0, 0, 0);

$date_2->setDate(2015, 02, 05);
$date_2->setTime(0, 0, 0);

$diff = $date_1->diff($date_2);
echo '$diff: ' . $diff->format('%d days') . '<br>';

// OR:
$date_1->add(new DateTimeInterval('P1Y'); // Adds 1 year to $date_1, check out the DateTimeInterval class.
echo '$date_1 is now: ' . $date_1->format('Y-m-d H:i:s') . '<br>';
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.