# the_date()

URL: https://chugunov.pro/api-wordpress/functions/the_date/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 0.71.

## Сигнатура

```php
the_date( string $format = '', string $before = '', string $after = '', bool $display = true ): string|null
```

## Описание

Дата выводится только в том случае, если дата текущей записи отличается от предыдущей выведенной.
То есть за каждый день из показанных в цикле записей выводится только одна дата, даже если функция вызывается несколько раз для каждой записи.
HTML-вывод можно изменить фильтром 'the_date'.
Строку с датой можно изменить фильтром 'get_the_date'.

## Параметры

- `$format` `string` — необязательный, по умолчанию `''`. Формат даты PHP. По умолчанию используется опция 'date_format'.
- `$before` `string` — необязательный, по умолчанию `''`. Вывод перед датой.
- `$after` `string` — необязательный, по умолчанию `''`. Вывод после даты.
- `$display` `bool` — необязательный, по умолчанию `true`. Выводить дату или возвращать её.

## Возвращаемое значение

`string|null`

## Исходный код

Файл: `wp-includes/general-template.php:2686`

```php
function the_date( $format = '', $before = '', $after = '', $display = true ) {
	global $currentday, $previousday;

	$the_date = '';

	if ( is_new_day() ) {
		$the_date    = $before . get_the_date( $format ) . $after;
		$previousday = $currentday;
	}

	/**
	 * Filters the date of the post, for display.
	 *
	 * @since 0.71
	 *
	 * @param string $the_date The formatted date string.
	 * @param string $format   PHP date format.
	 * @param string $before   HTML output before the date.
	 * @param string $after    HTML output after the date.
	 */
	$the_date = apply_filters( 'the_date', $the_date, $format, $before, $after );

	if ( $display ) {
		echo $the_date;
	} else {
		return $the_date;
	}
}
```

## История изменений

- 0.71 — Introduced.

## Связанные

Использует: [`get_the_date`](https://chugunov.pro/api-wordpress/functions/get_the_date/), [`is_new_day`](https://chugunov.pro/api-wordpress/functions/is_new_day/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/the_date/
