mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 23:35:45 +01:00
1 KiB
1 KiB
DateTime
DateTime()DateTime(string $format)
Validates whether an input is a date/time or not. The $format argument should
be in accordance to PHP's date() function.
v::dateTime()->validate('2009-01-01'); // true
Also accepts strtotime values:
v::dateTime()->validate('now'); // true
And DateTimeInterface instances:
v::dateTime()->validate(new DateTime()); // true
v::dateTime()->validate(new DateTimeImmutable()); // true
You can pass a format when validating strings:
v::dateTime('Y-m-d')->validate('01-01-2009'); // false
Format has no effect when validating DateTime instances.
Message template for this validator includes {{format}}.
Categorization
- Date and Time
Changelog
| Version | Description |
|---|---|
| 2.2.4 | v::dateTime('z') is no longer supported. |
| 2.0.0 | Created |
See also: