WordPress.org

Codex

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

Function Reference/get the date

Description

The get_the_date template tag retrieves the date the current $post was written. Unlike the_date() this tag will always return the date. Modify output with 'get_the_date' filter.

Usage

<?php $pfx_date get_the_date$format$post_id ); ?>

Parameters

$format
(string) (optional) PHP date format.
Default: the date_format option ('Date Format' on Settings > General panel)
$post
(integer) (optional) The ID of the post you'd like to fetch. By default the current post is fetched.
Default: null

Return

(string) The formatted date string

Filter

Changelog

  • 3.0.0 : New template tag.

Examples

Default Usage

<span class="entry-date"><?php echo get_the_date(); ?></span>

Source Code

get_the_date() is located in wp-includes/general-template.php.

Related

get_calendar(), get_day_link(), get_month_link(), get_the_date(), get_the_time(), get_year_link(), single_month_title(), the_date(), the_date_xml(), the_modified_date(), get_the_modified_date(), the_modified_time(), get_the_modified_time(), the_time()

See also index of Function Reference and index of Template Tags.
This page is marked as incomplete. You can help Codex by expanding it.