hi i stored a date that is taken from form in a variable using php and now i want to check whether the date is in the season or not..
the code i written is as follows:
$year = 2012;
$month1 = $_POST["month1"];
$date = $_POST["date"];
$result = "{$year}/{$month1}/{$date}";
echo $result;
and now
// finding first saturday in febraury
$saturday = strtotime('First Saturday '.date('F o', mktime(0,0,0, $month, 1, $year)));
echo "this is the first saturday in the given year:";
echo date('Y/m/d', $saturday);
// calculating first 12 weeks after the first saturday
echo "<br/>";
$season1 = strtotime ( '+12 week' , $saturday);
echo "<br/>this is the first season:";
echo date('Y/m/d', $season1);
echo "<br/>";
// calculating the one week gap after the first 12 weeks
$season2 = strtotime ('+1 week' , $season1);
echo "<br/>this is the first week break:";
echo date('Y/m/d', $season2);
echo "<br/>";
Here what i need to do is to check whether the date given by the user is in season1 or season2..for doing so i tried as
if ($result <= $season1)
{
echo "League yet to be opened";
}
else
{
echo "league 1 is opened";
}
but the condition is not checking here, and like wise i need to check the date entered by the user with 8 seasons how can i do that….any help is much appreciated….thanks in advance..
I’d advice you use such organisation of code and logic
Define current date from POSTed
Don’t forget to became sure data is safe
Year, month and date (day) MUST be numerical, for this logic to work.
Define your seasons array
Process data to define season
Test for errors and echo resulting season
It’s general logic for simple and clear solution of your task, I haven’t tested it.