Inspekt\Inspekt::isDate PHP Method

isDate() public static method

Returns true if value is a valid date, false otherwise. The date is required to be in ISO 8601 format.
public static isDate ( mixed $value ) : boolean
$value mixed
return boolean
    public static function isDate($value)
    {
        list($year, $month, $day) = sscanf($value, '%d-%d-%d');
        return checkdate($month, $day, $year);
    }

Usage Example

Beispiel #1
0
 /**
  * Generated from @assert ('2-6-30') === TRUE.
  */
 public function testIsDate4()
 {
     $this->assertSame(true, Inspekt::isDate('2-6-30'));
 }