get_the_time

Advertisement

Summery Summery

Retrieve the time at which the post was written.

Syntax Syntax

get_the_time( string $format = '', int|WP_Post $post = null )

Parameters Parameters

$format

(Optional) Format to use for retrieving the time the post was written. Either 'G', 'U', or PHP date format defaults to the value specified in the time_format option.

Default value: ''

$post

(Optional) WP_Post object or ID. Default is global $post object.

Default value: null

Return Return

(string|int|false) Formatted date string or Unix timestamp if $format is 'U' or 'G'. False on failure.

Source Source

File: wp-includes/general-template.php

	if ( ! $post ) {
		return false;
	}

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

	$the_date = get_post_time( $_format, false, $post, true );

	/**
	 * Filters the date a post was published.
	 *
	 * @since 3.0.0
	 *
	 * @param string      $the_date The formatted date.
	 * @param string      $format   PHP date format. Defaults to 'date_format' option
	 *                              if not specified.
	 * @param int|WP_Post $post     The post object or ID.
	 */
	return apply_filters( 'get_the_date', $the_date, $format, $post );
}

/**
 * Display the date on which the post was last modified.
 *
 * @since 2.1.0
 *

Advertisement

Changelog Changelog

Changelog
Version Description
1.5.0 Introduced.

Advertisement

Leave a Reply