Hi all,
I am trying to start date and end date which is running in my local machine but when I am trying to run online it is not working . here is the code:
echo " ONE";
$pDate = date('Y-m-d');
$curdate= (explode("-",$pDate));
echo $curdate[1]."<br>";
echo $curdate[2]."<br>";
$date=$curdate[1];
switch ($date)
{
case "01": echo "January!";
$month="Jan";
$days=$curdate[2];
$upperBound = new DateTime("Mar 31");
$lowerBound = new DateTime("Jan 01");
$checkDate = new DateTime($month." ".$days);
if ($lowerBound < $upperBound)
{
$between = $lowerBound < $checkDate && $checkDate < $upperBound;
echo "within range".$between;
$d1=strtotime("Mar 31");
$d2=ceil(($d1-time())/60/60/24);
echo "There are " . $d2 ." days until 31st of March.". "<br>";
$NewDate=Date('Y-m-d', strtotime("+$d2 days"));
$startdate = $NewDate;
$enddate = date('Y-m-d', strtotime($startdate) + strtotime("+365 day", 0));
echo $startdate. "<br>";
echo $pDate. "<br>";
echo $enddate. "<br>";
}
else
{
$between = $checkDate < $upperBound || $checkDate > $lowerBound;
echo "not within range".$between;
}
var_dump($between);
break;
case "02": echo "February!";
$month="Feb";
$days=$curdate[2];
$upperBound = new DateTime("Mar 31");
$lowerBound = new DateTime("Jan 01");
$checkDate = new DateTime($month." ".$days);
if ($lowerBound < $upperBound)
{
$between = $lowerBound < $checkDate && $checkDate < $upperBound;
echo "within range".$between;
$d1=strtotime("Mar 31");
$d2=ceil(($d1-time())/60/60/24);
echo "There are " . $d2 ." days until 31st of March.". "<br>";
$NewDate=Date('Y-m-d', strtotime("+$d2 days"));
$startdate = $NewDate;
$enddate = date('Y-m-d', strtotime($startdate) + strtotime("+365 day", 0));
echo $pDate. "<br>";
echo $enddate. "<br>";
}
else
{
$between = $checkDate < $upperBound || $checkDate > $lowerBound;
echo "not within range".$between;
}
var_dump($between);
break;
case "03": echo "March!";
$month="Mar";
$days=$curdate[2];
$upperBound = new DateTime("Mar 31");
$lowerBound = new DateTime("Jan 01");
$checkDate = new DateTime($month." ".$days);
if ($lowerBound < $upperBound)
{
$between = $lowerBound < $checkDate && $checkDate < $upperBound;
echo "within range".$between;
$d1=strtotime("Mar 31");
$d2=ceil(($d1-time())/60/60/24);
echo "There are " . $d2 ." days until 31st of March.". "<br>";
$NewDate=Date('Y-m-d', strtotime("+$d2 days"));
$startdate = $NewDate;
$enddate = date('Y-m-d', strtotime($startdate) + strtotime("+365 day", 0));
echo $pDate. "<br>";
echo $enddate. "<br>";
}
else
{
$between = $checkDate < $upperBound || $checkDate > $lowerBound;
echo "not within range".$between;
}
var_dump($between);
break;
case "04": echo "April!";
$month="April";
$days=$curdate[2];
$upperBound = new DateTime("Jun 30");
$lowerBound = new DateTime("Apr 01");
$checkDate = new DateTime($month." ".$days);
if ($lowerBound < $upperBound)
{
$between = $lowerBound < $checkDate && $checkDate < $upperBound;
echo "within range".$between;
$d1=strtotime("June 31");
$d2=ceil(($d1-time())/60/60/24);
echo "There are " . $d2 ." days until 30th of June.". "<br>";
$NewDate=Date('Y-m-d', strtotime("+$d2 days"));
$startdate = $NewDate;
$enddate = date('Y-m-d', strtotime($startdate) + strtotime("+364 day", 0));
echo $pDate. "<br>";
echo $enddate. "<br>";
}
else
{
$between = $checkDate < $upperBound || $checkDate > $lowerBound;
echo "not within range".$between;
}
var_dump($between);
break;
case "05": echo "May!";
$month="May";
$days=$curdate[2];
$upperBound = new DateTime("Jun 30");
$lowerBound = new DateTime("Apr 01");
$checkDate = new DateTime($month." ".$days);
if ($lowerBound < $upperBound)
{
$between = $lowerBound < $checkDate && $checkDate < $upperBound;
echo "within range".$between;
$d1=strtotime("June 31");
$d2=ceil(($d1-time())/60/60/24);
echo "There are " . $d2 ." days until 30th of June.". "<br>";
$NewDate=Date('Y-m-d', strtotime("+$d2 days"));
$startdate = $NewDate;
$enddate = date('Y-m-d', strtotime($startdate) + strtotime("+364 day", 0));
echo $pDate. "<br>";
echo $enddate. "<br>";
}
else
{
$between = $checkDate < $upperBound || $checkDate > $lowerBound;
echo "not within range".$between;
}
var_dump($between);
break;
case "06": echo "June! ";
$month="Jun";
$days=$curdate[2];
$upperBound = new DateTime("Jun 30");
$lowerBound = new DateTime("Apr 01");
$checkDate = new DateTime($month." ".$days);
if ($lowerBound < $upperBound)
{
$between = $lowerBound < $checkDate && $checkDate < $upperBound;
echo "within range".$between;
$d1=strtotime("June 31");
$d2=ceil(($d1-time())/60/60/24);
echo "There are " . $d2 ." days until 30th of June.". "<br>";
$NewDate=Date('Y-m-d', strtotime("+$d2 days"));
$startdate = $NewDate;
$enddate = date('Y-m-d', strtotime($startdate) + strtotime("+364 day", 0));
echo $pDate. "<br>";
echo $enddate. "<br>";
}
else
{
$between = $checkDate < $upperBound || $checkDate > $lowerBound;
echo "not within range".$between;
}
var_dump($between);
break;
case "07": echo "July!";
$month="Jul";
$days=$curdate[2];
$upperBound = new DateTime("Sep 30");
$lowerBound = new DateTime("Jul 01");
$checkDate = new DateTime($month." ".$days);
if ($lowerBound < $upperBound)
{
$between = $lowerBound < $checkDate && $checkDate < $upperBound;
echo "within range".$between;
$d1=strtotime("Sep 30");
$d2=ceil(($d1-time())/60/60/24);
echo "There are " . $d2 ." days until 30th of September.". "<br>";
$NewDate=Date('Y-m-d', strtotime("+$d2 days"));
$startdate = $NewDate;
$enddate = date('Y-m-d', strtotime($startdate) + strtotime("+365 day", 0));
echo $pDate. "<br>";
echo $enddate. "<br>";
}
else
{
$between = $checkDate < $upperBound || $checkDate > $lowerBound;
echo "not within range".$between;
}
var_dump($between);
break;
case "08": echo "August!";
$month="Aug";
$days=$curdate[2];
$upperBound = new DateTime("Sep 30");
$lowerBound = new DateTime("Jul 01");
$checkDate = new DateTime($month." ".$days);
if ($lowerBound < $upperBound)
{
$between = $lowerBound < $checkDate && $checkDate < $upperBound;
echo "within range".$between;
$d1=strtotime("Sep 30");
$d2=ceil(($d1-time())/60/60/24);
echo "There are " . $d2 ." days until 30th of September.". "<br>";
$NewDate=Date('Y-m-d', strtotime("+$d2 days"));
$startdate = $NewDate;
$enddate = date('Y-m-d', strtotime($startdate) + strtotime("+365 day", 0));
echo $pDate. "<br>";
echo $enddate. "<br>";
}
else
{
$between = $checkDate < $upperBound || $checkDate > $lowerBound;
echo "not within range".$between;
}
var_dump($between);
break;
case "09": echo "September!";
$month="Sep";
$days=$curdate[2];
$upperBound = new DateTime("Sep 30");
$lowerBound = new DateTime("Jul 01");
$checkDate = new DateTime($month." ".$days);
if ($lowerBound < $upperBound)
{
$between = $lowerBound < $checkDate && $checkDate < $upperBound;
echo "within range".$between;
$d1=strtotime("Sep 30");
$d2=ceil(($d1-time())/60/60/24);
echo "There are " . $d2 ." days until 30th of September.". "<br>";
$NewDate=Date('Y-m-d', strtotime("+$d2 days"));
$startdate = $NewDate;
$enddate = date('Y-m-d', strtotime($startdate) + strtotime("+365 day", 0));
echo $pDate. "<br>";
echo $enddate. "<br>";
}
else
{
$between = $checkDate < $upperBound || $checkDate > $lowerBound;
echo "not within range".$between;
}
var_dump($between);
break;
case "10": echo "October!";
$month="Oct";
$days=$curdate[2];
$upperBound = new DateTime("Dec 31");
$lowerBound = new DateTime("Oct 01");
$checkDate = new DateTime($month." ".$days);
if ($lowerBound < $upperBound)
{
$between = $lowerBound < $checkDate && $checkDate < $upperBound;
echo "within range".$between;
$d1=strtotime("Dec 31");
$d2=ceil(($d1-time())/60/60/24);
echo "There are " . $d2 ." days until 31st of December.". "<br>";
$NewDate=Date('Y-m-d', strtotime("+$d2 days"));
$startdate = $NewDate;
$enddate = date('Y-m-d', strtotime($startdate) + strtotime("+365 day", 0));
echo $pDate. "<br>";
echo $enddate. "<br>";
}
else
{
$between = $checkDate < $upperBound || $checkDate > $lowerBound;
echo "not within range".$between;
}
var_dump($between);
break;
case "11": echo "November!";
$month="Nov";
$days=$curdate[2];
$upperBound = new DateTime("Dec 31");
$lowerBound = new DateTime("Oct 01");
$checkDate = new DateTime($month." ".$days);
if ($lowerBound < $upperBound)
{
$between = $lowerBound < $checkDate && $checkDate < $upperBound;
echo "within range".$between;
$d1=strtotime("Dec 31");
$d2=ceil(($d1-time())/60/60/24);
echo "There are " . $d2 ." days until 31st of December.". "<br>";
$NewDate=Date('Y-m-d', strtotime("+$d2 days"));
$startdate = $NewDate;
$enddate = date('Y-m-d', strtotime($startdate) + strtotime("+365 day", 0));
echo $pDate. "<br>";
echo $enddate. "<br>";
}
else
{
$between = $checkDate < $upperBound || $checkDate > $lowerBound;
echo "not within range".$between;
}
var_dump($between);
break;
case "12": echo "December!";
$month="Dec";
$days=$curdate[2];
echo "Days ".$days;
$upperBound = new DateTime("Dec 31");
$lowerBound = new DateTime("Oct 01");
$checkDate = new DateTime($month." ".$days);
if ($lowerBound < $upperBound)
{
$between = $lowerBound < $checkDate && $checkDate < $upperBound;
echo "within range".$between;
$d1=strtotime("Dec 31");
$d2=ceil(($d1-time())/60/60/24);
echo "There are " . $d2 ." days until 31st of December.". "<br>";
$NewDate=Date('Y-m-d', strtotime("+$d2 days"));
$startdate = $NewDate;
$enddate = date('Y-m-d', strtotime($startdate) + strtotime("+365 day", 0));
echo $pDate. "<br>";
echo $enddate. "<br>";
}
else
{
$between = $checkDate < $upperBound || $checkDate > $lowerBound;
echo "not within range".$between;
}
var_dump($between);
break;
default:
echo "Your favorite date is out of range!";
}