You are here

function date_calc_compare_dates in Date 6.2

Same name and namespace in other branches
  1. 5.2 date_php4/date_php4_calc.inc \date_calc_compare_dates()
  2. 6 date_php4/date_php4_calc.inc \date_calc_compare_dates()

Compares two dates

Parameters

int $day1: the day of the month

int $month1: the month

int $year1: The 4 digit year. Do not add leading 0's for years prior to 1000.

int $day2: the day of the month

int $month2: the month

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 value

int 0 if the dates are equal. 1 if date 1 is later, -1 if date 1 is earlier.

File

date_php4/date_php4_calc.inc, line 1491

Code

function date_calc_compare_dates($day1, $month1, $year1, $day2, $month2, $year2) {
  $ndays1 = date_calc_date_to_days($day1, $month1, $year1);
  $ndays2 = date_calc_date_to_days($day2, $month2, $year2);
  if ($ndays1 == $ndays2) {
    return 0;
  }
  return $ndays1 > $ndays2 ? 1 : -1;
}