get_the_date() – Retrieve the date on which the post was written.

You appear to be a bot. Output may be restricted

Description

Retrieves the date on which the post was written.

Unlike the_date() this function will always return the date. Modify output with the get_the_date filter.

Usage

$string|int|false = get_the_date( $format, $post );

Parameters

$format
( string ) optional – Optional. PHP date format. Defaults to the 'date_format' option.
$post
( int|WP_Post ) optional – Optional. Post ID or WP_Post object. Default current post.

Returns

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

Source

File name: wordpress/wp-includes/general-template.php
Lines:

1 to 22 of 22
function get_the_date( $format = '', $post = null ) {
  $post = get_post( $post );

  if ( ! $post ) {
    return false;
  }

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

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

  
/**
 * Filters the date a post was published.
 *
 * @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( 'get_the_date', $the_date, $format, $post );
}
 

 View on GitHub View on Trac