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

Filters the date a post was published.

Parameters Parameters


(string) The formatted date.


(string) PHP date format.


(int|WP_Post) The post object or ID.

Top ↑

Source Source

File: wp-includes/general-template.php

View on Trac

Top ↑

Changelog Changelog

Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 content
    Contributed by stevenlinx

    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.