How to Check the Last Day in Month


Check the Last Day in Month
$startDate = "20150624";
$endDate = "20150722";
$startDate = strtotime($startDate);
$endDate = strtotime($endDate);
$dayLength = 60 * 60 * 24;
$checkDateRange = ($endDate - $startDate) / $dayLength;
$datesStartMonth = date('t', $startDate);

if ($checkDateRange > $datesStartMonth) {
echo $error = "Date range should be with in one month";
}
Share me!