Skip to content

Kirby 4.1.2

date

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

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

Parameters

Name Type Default
$value * string|null
$operator string|null null
$test string|null 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