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

Filters the date a post was published.

Parameters

$the_datestring|int
Formatted date string or Unix timestamp if $format is 'U' or 'G'.
$formatstring
PHP date format.
$postWP_Post
The post object.

Source

return apply_filters( 'get_the_date', $the_date, $format, $post );

Changelog

VersionDescription
3.0.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Example migrated from Codex:

    Below is a basic example on how to use the get_the_date filter to modify date format for a post type called ‘product’:

    add_filter( 'get_the_date', 'wpdocs_filter_publish_dates', 10, 3 );
    
    function wpdocs_filter_publish_dates( $the_date, $d, $post ) {
    	if ( is_int( $post) ) {
    		$post_id = $post;
    	} else {
    		$post_id = $post->ID;
    	}
    
    	if ( 'product' != get_post_type( $post_id ) )
    		return $the_date;
    
    	return date( 'Y-d-m - h:j:s', strtotime( $the_date ) );
    }

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