$minDate = (date("d") <= 5) ? date("Y-m-01", strtotime('-1 month')) : date("Y-m-01");
$maxDays = 5;
$datetime1 = date_create($oldDate);
$datetime2 = date_create($currentDate);
$interval = date_diff($datetime1, $datetime2);
if($interval->format('%a') >= $maxDays) {
die;
}