note 60403 added to function.strtotime

From: Date: Thu, 05 Jan 2006 23:22:03 +0000
Subject: note 60403 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-101276@lists.php.net to get a copy of this message
//function to compare existing date from database to the current date $check_array_deadline = explode("/", "08/24/2005");//this date is from database and in the format mm/dd/yyyy $a_year = $today["year"]; $a_month = $today["mon"]; $a_day = $today["mday"]; $b_year = $check_array_deadline[2]; $b_month = $check_array_deadline[0]; $b_day = $check_array_deadline[1]; $check_date = date_compare( $a_year, $a_month, $a_day, $b_year, $b_month, $b_day ); function date_compare ( $a_year, $a_month, $a_day, $b_year, $b_month, $b_day ) { $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; } ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60403 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60403&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60403&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60403&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60403&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60403&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60403&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60403&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60403&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101276) next »