WordPress.org

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Filter Reference/get the date

Description

get_the_date is a filter applied to posts publish dates.

Parameters

$the_date
(string) (required) The formatted date.
Default: None
$d
(string) (optional) PHP date format.
Default: 'date_format' option
$post
(int/WP_Post) (required) The post object or ID.
Default: None

Examples

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

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 ) );
}
add_action( 'get_the_date', 'my_project_filter_publish_dates', 10, 3 );

Change Log

Source File

Applied in get_the_date in wp-includes/general-template.php

Related

Filters