get_the_date( string $d = '', int|WP_Post $post = null )
Retrieve the date on which the post was written.
Description Description
Unlike the_date() this function will always return the date. Modify output with the ‘get_the_date’ filter.
Parameters Parameters
Return Return
(false|string) Date the current post was written. False on failure.
Source Source
File: wp-includes/general-template.php
function get_the_date( $d = '', $post = null ) { $post = get_post( $post ); if ( ! $post ) { return false; } if ( '' == $d ) { $the_date = get_post_time( get_option( 'date_format' ), false, $post, true ); } else { $the_date = get_post_time( $d, false, $post, true ); } /** * Filters the date a post was published. * * @since 3.0.0 * * @param string $the_date The formatted date. * @param string $d PHP date format. Defaults to 'date_format' option * if not specified. * @param int|WP_Post $post The post object or ID. */ return apply_filters( 'get_the_date', $the_date, $d, $post ); }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
To get ISO 8601 date for meta, use
All PHP date formats can be found here: http://php.net/manual/en/function.date.php
To make the date appear as “Monday January 11, 2017”, for example, use
To make the date appear as “Wed Jan 9”, for example, use
Default Usage
If you want to display the publish date in Ymd format (ex: 20191231):