# get_comment_time()

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

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

## Сигнатура

```php
get_comment_time( string $format = '', bool $gmt = false, bool $translate = true, int|WP_Comment $comment_id ): string
```

## Описание

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

## Параметры

- `$format` `string` — необязательный, по умолчанию `''`. Формат даты PHP. По умолчанию используется опция 'time_format'.
- `$gmt` `bool` — необязательный, по умолчанию `false`. Использовать ли дату по GMT.
- `$translate` `bool` — необязательный, по умолчанию `true`. Переводить ли время (для использования в лентах).
- `$comment_id` `int|WP_Comment` — необязательный. WP_Comment или ID комментария, для которого нужно получить время.
  
  По умолчанию — текущий комментарий.

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

`string`

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

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

```php
function get_comment_time( $format = '', $gmt = false, $translate = true, $comment_id = 0 ) {
	$comment = get_comment( $comment_id );

	if ( null === $comment ) {
		return '';
	}

	$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;

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

	$comment_time = mysql2date( $_format, $comment_date, $translate );

	/**
	 * Filters the returned comment time.
	 *
	 * @since 1.5.0
	 *
	 * @param string|int $comment_time The comment time, formatted as a date string or Unix timestamp.
	 * @param string     $format       PHP date format.
	 * @param bool       $gmt          Whether the GMT date is in use.
	 * @param bool       $translate    Whether the time is translated.
	 * @param WP_Comment $comment      The comment object.
	 */
	return apply_filters( 'get_comment_time', $comment_time, $format, $gmt, $translate, $comment );
}
```

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

- 6.2.0 — Added the $comment_id parameter.
- 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/).
Используется в: `Walker_Comment::comment`, `Walker_Comment::html5_comment`, [`comment_time`](https://chugunov.pro/api-wordpress/functions/comment_time/).

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