Uma área de pesquisa sobre o WordPress para devs e autores do tema



get_post_time ›

Desde2.0.0
Obsoleton/a
get_post_time ( $d = 'U', $gmt = false, $post = null, $translate = false )
Parâmetros: (4)
  • (string) $d Optional. Format to use for retrieving the time the post was written. Either 'G', 'U', or php date format. Default 'U'.
    Required: No
    Padrão: 'U'
  • (bool) $gmt Optional. Whether to retrieve the GMT time. Default false.
    Required: No
    Padrão: false
  • (int|WP_Post) $post WP_Post object or ID. Default is global $post object.
    Required: No
    Padrão: null
  • (bool) $translate Whether to translate the time string. Default false.
    Required: No
    Padrão: false
Retorna:
  • (string|int|false) Formatted date string or Unix timestamp if `$id` is 'U' or 'G'. False on failure.
Definido em:
Codex:

Retrieve the time at which the post was written.



Fonte

function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
	$post = get_post($post);

	if ( ! $post ) {
		return false;
	}

	if ( $gmt )
		$time = $post->post_date_gmt;
	else
		$time = $post->post_date;

	$time = mysql2date($d, $time, $translate);

	/**
	 * Filters the localized time a post was written.
	 *
	 * @since 2.6.0
	 *
	 * @param string $time The formatted time.
	 * @param string $d    Format to use for retrieving the time the post was written.
	 *                     Accepts 'G', 'U', or php date format. Default 'U'.
	 * @param bool   $gmt  Whether to retrieve the GMT time. Default false.
	 */
	return apply_filters( 'get_post_time', $time, $d, $gmt );
}