src/Utility/Random.php
public static function dob($min = 18, $max = 100) {
		$dobYear = (int)date('Y') - (static::int($min, $max));

		$dobMonth = static::int(1, 12);

		if ($dobMonth == 2) {
			// leap year?
			if ($dobYear % 4 || $dobYear % 400) {
				$maxDays = 29;
			} else {
				$maxDays = 28;
			}
		} elseif (in_array($dobMonth, [4, 6, 9, 11])) {
			$maxDays = 30;
		} else {
			$maxDays = 31;
		}

		$dobDay = static::int(1, $maxDays);

		$dob = sprintf('%4d-%02d-%02d', $dobYear, $dobMonth, $dobDay);
		return $dob;
	}
public static function dob($min = 18, $max = 100) {
		$dobYear = (int)date('Y') - (static::int($min, $max));

		$dobMonth = static::int(1, 12);

		if ($dobMonth == 2) {
			// leap year?
			if ($dobYear % 4 || $dobYear % 400) {
				$maxDays = 29;
			} else {
				$maxDays = 28;
			}
		} elseif (in_array($dobMonth, [4, 6, 9, 11])) {
			$maxDays = 30;
		} else {
			$maxDays = 31;
		}

		$dobDay = static::int(1, $maxDays);

		$dob = sprintf('%4d-%02d-%02d', $dobYear, $dobMonth, $dobDay);
		return $dob;
	}
public static function dob ( $ min = 18 , $ max = 100 ) { $ dobYear = ( int ) date ( 'Y' ) - ( static :: int ( $ min , $ max ) ) ; $ dobMonth = static :: int ( 1 , 12 ) ; if ( $ dobMonth == 2 ) { // leap year? if ( $ dobYear % 4 || $ dobYear % 400 ) { $ maxDays = 29 ; } else { $ maxDays = 28 ; } } elseif ( in_array ( $ dobMonth , [ 4 , 6 , 9 , 11 ] ) ) { $ maxDays = 30 ; } else { $ maxDays = 31 ; } $ dobDay = static :: int ( 1 , $ maxDays ) ; $ dob = sprintf ( '%4d-%02d-%02d' , $ dobYear , $ dobMonth , $ dobDay ) ; return $ dob ; }
Returns a date of birth within the specified age range

@param int $min minimum age in years
@param int $max maximum age in years
@return string Dob a db (ISO) format datetime string
Returns a date of birth within the specified age range