Skip to content

Kirby 5.0.4

date

Checks for a valid date or compares two dates with each other.

V::date(string|null $value, string|null $operator = null, string|null $test = null): bool

Parameters

Name Type Default
$value stringornull no default value
$operator stringornull null
$test stringornull null

Return type

bool

Checking the validity of a date string

In your code

if (V::date('2012-12-12')) {
  echo 'Yay, valid!';
}

In fields

fields:
  example:
    label: Example field
    type: text
    validate: date

Comparing two date strings

if (V::date('2012-12-12', '>=', '2010-10-10')) {
  echo 'Yay, passed!';
}

In fields

fields:
  example:
    label: Example field
    type: text
    validate:
      date:
        - ">="
        - 2010-10-10