note 56761 deleted from function.mcal-date-compare by philip
| From: | philip@php.net | Date: | Tue, 27 May 2008 00:26:09 +0000 |
| Subject: | note 56761 deleted from function.mcal-date-compare by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-139825@lists.php.net to get a copy of this message | ||
Note Submitter: asharm4 at ilstu dot edu
----
//this function compares any date to current date and returns results in form of integers..
function date_compare ( $b_year, $b_month, $b_day )
{
$a_year = $today["year"];
$a_month = $today["mon"];
$a_day = $today["mday"];
$final_result = 9; //set it to random right now
if($a_year >$b_year)
{
$final_result = 1; //the year 1 is greater then year 2 so no more check required
}//year greater
else if($a_year == $b_year) //the years are the same ..so check the month
{
if($a_month > $b_month)
{
$final_result = 2; //the months are greater and so no more checks needed
}//greater month check
else
if($a_month == $b_month)//same months ..so check dates
{
if($a_day > $b_day)
{
$final_result = 3; //the days solve the problem :)
}
else if($a_day == $b_day)
{
$final_result = 4; //the dates are identical too..so date1 becomes equal to date 2
}
else
{
$final_result = -3; //the date1 < $date 2
}
}//equal month check
else
{
$final_result = -2;
}//month1 < month2
}//year same
else
{
$final_result = -1; //the year 1 is smaller then year 2 ..hence date1 < date2
}
return $final_result;
}