respect-validation/docs/DateTime.md
Emmerson Siqueira 9eb159f3d9
Rename "MaximumAge" and "MinimumAge" rules
Those rules were renamed to keep consistent with other rules such as
'Max' and 'Min'.

Signed-off-by: Emmerson Siqueira <emmersonsiqueira@gmail.com>
2018-05-31 17:01:15 +02:00

1,016 B

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}}.

Changelog

Version Description
2.0.0 Renamed from Date to DateTime
0.3.9 Created as Date

See also: