# get_comment_date()

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

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

## Сигнатура

```php
get_comment_date( string $format = '', int|WP_Comment $comment_id ): string
```

## Описание

Получает дату текущего комментария.

## Параметры

- `$format` `string` — необязательный, по умолчанию `''`. Формат даты PHP. По умолчанию используется опция 'date_format'.
- `$comment_id` `int|WP_Comment` — необязательный. WP_Comment или ID комментария, для которого нужно получить дату.
  
  По умолчанию — текущий комментарий.

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

`string`

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

Файл: `wp-includes/comment-template.php:613`

```php
function get_comment_date( $format = '', $comment_id = 0 ) {
	$comment = get_comment( $comment_id );

	$_format = ! empty( $format ) ? $format : get_option( 'date_format' );

	$comment_date = mysql2date( $_format, $comment->comment_date );

	/**
	 * Filters the returned comment date.
	 *
	 * @since 1.5.0
	 *
	 * @param string|int $comment_date Formatted date string or Unix timestamp.
	 * @param string     $format       PHP date format.
	 * @param WP_Comment $comment      The comment object.
	 */
	return apply_filters( 'get_comment_date', $comment_date, $format, $comment );
}
```

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

- 4.4.0 — Added the ability for $comment_id to also accept a WP_Comment object.
- 1.5.0 — Introduced.

## Связанные

Использует: [`mysql2date`](https://chugunov.pro/api-wordpress/functions/mysql2date/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`get_option`](https://chugunov.pro/api-wordpress/functions/get_option/), [`get_comment`](https://chugunov.pro/api-wordpress/functions/get_comment/).
Используется в: `WP_Comments_List_Table::column_date`, `Walker_Comment::comment`, `Walker_Comment::html5_comment`, [`comment_date`](https://chugunov.pro/api-wordpress/functions/comment_date/).

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