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

Filters the date a post was published.


Parameters

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

Top ↑

Source

File: wp-includes/general-template.php. View all references

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


Top ↑

Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by Steven Lin

    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_action( 'get_the_date', 'my_project_filter_publish_dates', 10, 3 );
    
    function my_project_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.