# date

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

****

- Source: <https://github.com/getkirby/kirby/tree/5.5.3/src/Toolkit/V.php#L321>

****

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

## Parameters

| Name | Type | Default | Description |
| ---- | ---- | ---- | ---- |
| `$value` | `string` or `null` | – | – |
| `$operator` | `string` or `null` | `null` | – |
| `$test` | `string` or `null` | `null` | – |

## Return type

`bool`

## Checking the validity of a date string

### In your code

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

### In fields

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

## Comparing two date strings

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

### In fields

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