функция
since 1.5.0
get_the_time()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
get_the_time( string $format = '', int|WP_Post|null $post = null ): string|int|false
Описание
Извлекает время записи.
Параметры
$format
string
необязательный
= ''
Формат для получения времени написания записи. Принимает 'G', 'U' или формат даты PHP.
По умолчанию используется значение опции 'time_format'.
$post
int|WP_Post|null
необязательный
= null
ID записи или объект записи. По умолчанию — глобальный объект $post .
Возвращаемое значение
string|int|false
$format 'U' 'G'
Исходный код
wp-includes/general-template.php:2852
function get_the_time( $format = '', $post = null ) {
$post = get_post( $post );
if ( ! $post ) {
return false;
}
$_format = ! empty( $format ) ? $format : get_option( 'time_format' );
$the_time = get_post_time( $_format, false, $post, true );
/**
* Filters the time of the post.
*
* @since 1.5.0
*
* @param string|int $the_time Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
* @param string $format Format to use for retrieving the time the post
* was written. Accepts 'G', 'U', or PHP date format.
* @param WP_Post $post Post object.
*/
return apply_filters( 'get_the_time', $the_time, $format, $post );
}
История изменений
| Версия | Описание |
|---|---|
| 1.5.0 | Introduced. |

