1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39:
<?php
/**
* Class DateTime
* @package Faulancer\Form\Validator
*/
namespace Faulancer\Form\Validator\Type;
use Faulancer\Form\Validator\AbstractValidator;
/**
* Class DateTime
*/
class DateTime extends AbstractValidator
{
/**
* The error message as key for translation
* @var string
*/
protected $errorMessage = 'validator_invalid_datetime_format';
/**
* Proof date validation with the \DateTime object
* @param string $data
* @return boolean
*/
public function process($data)
{
try {
$date = new \DateTime($data);
return true;
} catch (\Exception $e) {
// We just validate the correct format with \DateTime and want a boolean return value
}
return false;
}
}