Bazujące na WordPress narzędzie wyszukiwania dla deweloperów i twórców motywów.



get_post_time ›

Od2.0.0
Przestarzałyn/a
get_post_time ( $d = 'U', $gmt = false, $post = null, $translate = false )
Parametry: (4)
  • (string) $d Optional. Format to use for retrieving the time the post was written. Either 'G', 'U', or php date format. Default 'U'.
    Wymagane: Nie
    Domyślny: 'U'
  • (bool) $gmt Optional. Whether to retrieve the GMT time. Default false.
    Wymagane: Nie
    Domyślny: false
  • (int|WP_Post) $post WP_Post object or ID. Default is global $post object.
    Wymagane: Nie
    Domyślny: null
  • (bool) $translate Whether to translate the time string. Default false.
    Wymagane: Nie
    Domyślny: false
Powrót:
  • (string|int|false) Formatted date string or Unix timestamp if `$d` is 'U' or 'G'. False on failure.
Zdefiniowane na:
Codex:

Retrieve the time at which the post was written.



Źródło

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 );
}