# $field->toDate()

Converts the field value to a timestamp or a formatted date

****

- Source: <https://github.com/getkirby/kirby/tree/5.5.3/config/methods.php#L118>

****

```php
$field->toDate(string|IntlDateFormatter|null $format = null, string|null $fallback = null): string|int|null
```

## Parameters

| Name | Type | Default | Description |
| ---- | ---- | ---- | ---- |
| `$format` | `string`, `IntlDateFormatter` or `null` | `null` | PHP date formatting string |
| `$fallback` | `string` or `null` | `null` | Fallback string for `strtotime` |

## Return types

`string`, `int` or `null`

This method modifies the existing `$field` object it is applied to and returns it again.


## Examples

### To a Unix timestamp
```php
<?= $page->createdAt()->toDate() ?>
```

### To a formatted date string
```php
<?= $page->createdAt()->toDate('d.m.Y') ?>
```

### With fallback parameter
```php
<?= $page->createdAt()->toDate('d.m.Y', 'now') ?>
```

Check out PHP's date function docs for all available formatting options: https://www.php.net/manual/en/function.date.php.

If you use the `intl` date handler for localized date strings, the format syntax is different: https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax.

The `strftime` date handler is deprecated as of PHP 8.1, and should not be used for new projects.