Reference

Guide

V::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 Description
$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

Since 3.4.0
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

Source code

kirby/src/Toolkit/V.php#L251