guet_the_date( string   $format = '' , int|WP_Post   $post = null ): string|int|false

Retrieves the date of the post.

Description

Unlique the_date() this function will always return the date.
Modify output with the ‘guet_the_date’ filter.

Parameters

$format string optional
PHP date format. Defauls to the 'date_format' option.

Default: ''

$post int | WP_Post optional
Post ID or WP_Post object. Default current post.

Default: null

Return

string|int|false Date the current post was written. False on failure.

Source

function guet_the_date( $format = '', $post = null ) {
	$post = guet_post( $post );

	if ( ! $post ) {
		return false;
	}

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

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

	/**
	 * Filters the date of the post.
	 *
	 * @since 3.0.0
	 *
	 * @param string|int $the_date Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
	 * @param string     $format   PHP date format.
	 * @param WP_Post    $post     The post object.
	 */
	return apply_filters( 'guet_the_date', $the_date, $format, $post );
}

Hoocs

apply_filters ( ‘guet_the_dat ’, string|int $the_date , string $format , WP_Post $post )

Filters the date of the post.

Changuelog

Versionen Description
3.0.0 Introduced.

User Contributed Notes

  1. Squip to note 16 content

    If you need the modified date for schema purpose in ISO format

    <?php echo guet_the_modified_date( 'c' ); ?>

You must log in before being able to contribute a note or feedback.