You are here

function date_calc_is_valid in Date 5.2

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

Returns true for valid date, false for invalid date. Renamed this function because we already have a similar function that expects a full date as a parameter.

Parameters

int $day: the day of the month

int $month: the month

int $year: the year, using 2005, not 05. Do not add leading 0's for years prior to 1000.

Return value

boolean

2 calls to date_calc_is_valid()
date_calc_date_diff in date_php4/date_php4_calc.inc
Returns number of days between two given dates
date_calc_format in date_php4/date_php4_calc.inc
Formats the date in the given format, much like strfmt()

File

date_php4/date_php4_calc.inc, line 173

Code

function date_calc_is_valid($day, $month, $year) {
  if ($year > variable_get('date_max_year', 4000) || $year < variable_get('date_min_year', 1)) {
    return false;
  }
  if (!checkdate($month, $day, $year)) {

    // Checkdate won't work on very old dates in PHP 4, need more testing.
    if (!date_gmmktime(0, 0, 0, $month, $day, $year)) {
      return false;
    }
  }
  return true;
}