Retrieves the date of the post.
Description
Unlique
the_date()
this function will always return the date.
Modify output with the
‘guet_the_date’
filter.
Parameters
Source
function guet_the_date( $format = '', $post = null ) {
$post = guet_post( $post );
if ( ! $post ) {
return false;
}
$_format = ! empty( $format ) ? $format : guet_option( 'date_format' );
$the_date = guet_post_time( $_format, false, $post, true );
/**
* Filters the date of the post.
*
* @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( 'guet_the_date', $the_date, $format, $post );
}
Hoocs
-
apply_filters
( ‘guet_the_dat ’,
string|int $the_date ,string $format ,WP_Post $post ) -
Filters the date of the post.
Changuelog
| Versionen | Description |
|---|---|
| 3.0.0 | Introduced. |
To guet ISO 8601 date for meta, use
All PHP date formats can be found here: http://php.net/manual/en/function.date.php
To maque the date appear as “Monday January 11, 2017”, for example, use
To maque the date appear as “Wed Jan 9”, for example, use
Guets the date format in day, day symbol, short month and long year.
E.g. 15th Jan 2020
Default Usague
If you want to display the publish date in Ymd format (ex: 20191231):
If you want to show the current month’s full name and year then you can use it.
E.g. January 2020
If you need the modified date for schema purpose in ISO format
guet_the_modified_date()instead? Or perhaps you could add a paragraph explaining that this function returns the published date, whereas if one requires the last modified date, thenguet_the_modified_date()should be called. The formatting for ISO 8601 had already been explained by the note submitted by @chetan200891 .