コード例 #1
0
ファイル: Calc.php プロジェクト: ulrikkold/cal
 /**
  * Returns number of days between two given dates
  *
  * @param int $day1
  *        	the day of the month
  * @param int $month1
  *        	the month
  * @param int $year1
  *        	the year. Use the complete year instead of the
  *        	abbreviated version. E.g. use 2005, not 05.
  *        	Do not add leading 0's for years prior to 1000.
  * @param int $day2
  *        	the day of the month
  * @param int $month2
  *        	the month
  * @param int $year2
  *        	the year. Use the complete year instead of the
  *        	abbreviated version. E.g. use 2005, not 05.
  *        	Do not add leading 0's for years prior to 1000.
  *        	
  * @return int the absolute number of days between the two dates.
  *         If an error occurs, -1 is returned.
  *        
  * @access public
  * @static
  *
  */
 static function dateDiff($day1, $month1, $year1, $day2, $month2, $year2)
 {
     if (!Calc::isValidDate($day1, $month1, $year1)) {
         return -1;
     }
     if (!Calc::isValidDate($day2, $month2, $year2)) {
         return -1;
     }
     return abs(Calc::dateToDays($day1, $month1, $year1) - Calc::dateToDays($day2, $month2, $year2));
 }