GetOptionKit\ValueType\DateTimeType::test PHP Méthode

test() public méthode

public test ( $value )
    public function test($value)
    {
        return DateTime::createFromFormat($this->option['format'], $value) !== false;
    }

Usage Example

Exemple #1
0
 public function testDateTimeType()
 {
     $type = new DateTimeType(['format' => 'Y-m-d']);
     $this->assertTrue($type->test('2016-12-30'));
     $a = $type->parse('2016-12-30');
     $this->assertEquals(2016, $a->format('Y'));
     $this->assertEquals(12, $a->format('m'));
     $this->assertEquals(30, $a->format('d'));
     $this->assertFalse($type->test('foo'));
 }
DateTimeType