Skip to content

Kirby 3.8.4

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
$operator string null
$test string 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