the_date

The timeline below displays how wordpress function the_date has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Displays or retrieves the date the current post was written (once per date)
 *
 * Will only output the date if the current post's date is different from the
 * previous one output.
 *
 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
 * function is called several times for each post.
 *
 * HTML output can be filtered with 'the_date'.
 * Date string output can be filtered with 'get_the_date'.
 *
 * @since 0.71
 *
 * @global string $currentday  The day of the current post in the loop.
 * @global string $previousday The day of the previous post in the loop.
 *
 * @param string $format  Optional. PHP date format. Defaults to the 'date_format' option.
 * @param string $before  Optional. Output before the date. Default empty.
 * @param string $after   Optional. Output after the date. Default empty.
 * @param bool   $display Optional. Whether to echo the date or return it. Default true.
 * @return string|void String if retrieving.
 */
function the_date($format = '', $before = '', $after = '', $display = true)
{
    global $currentday, $previousday;
    $the_date = '';
    if (is_new_day()) {
        $the_date = $before . get_the_date($format) . $after;
        $previousday = $currentday;
    }
    /**
     * Filters the date a post was published for display.
     *
     * @since 0.71
     *
     * @param string $the_date The formatted date string.
     * @param string $format   PHP date format.
     * @param string $before   HTML output before the date.
     * @param string $after    HTML output after the date.
     */
    $the_date = apply_filters('the_date', $the_date, $format, $before, $after);
    if ($display) {
        echo $the_date;
    } else {
        return $the_date;
    }
}

WordPress Version: 6.1

/**
 * Displays or retrieves the date the current post was written (once per date)
 *
 * Will only output the date if the current post's date is different from the
 * previous one output.
 *
 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
 * function is called several times for each post.
 *
 * HTML output can be filtered with 'the_date'.
 * Date string output can be filtered with 'get_the_date'.
 *
 * @since 0.71
 *
 * @global string $currentday  The day of the current post in the loop.
 * @global string $previousday The day of the previous post in the loop.
 *
 * @param string $format Optional. PHP date format. Defaults to the 'date_format' option.
 * @param string $before Optional. Output before the date. Default empty.
 * @param string $after  Optional. Output after the date. Default empty.
 * @param bool   $echo   Optional. Whether to echo the date or return it. Default true.
 * @return string|void String if retrieving.
 */
function the_date($format = '', $before = '', $after = '', $echo = true)
{
    global $currentday, $previousday;
    $the_date = '';
    if (is_new_day()) {
        $the_date = $before . get_the_date($format) . $after;
        $previousday = $currentday;
    }
    /**
     * Filters the date a post was published for display.
     *
     * @since 0.71
     *
     * @param string $the_date The formatted date string.
     * @param string $format   PHP date format.
     * @param string $before   HTML output before the date.
     * @param string $after    HTML output after the date.
     */
    $the_date = apply_filters('the_date', $the_date, $format, $before, $after);
    if ($echo) {
        echo $the_date;
    } else {
        return $the_date;
    }
}

WordPress Version: 5.6

/**
 * Display or Retrieve the date the current post was written (once per date)
 *
 * Will only output the date if the current post's date is different from the
 * previous one output.
 *
 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
 * function is called several times for each post.
 *
 * HTML output can be filtered with 'the_date'.
 * Date string output can be filtered with 'get_the_date'.
 *
 * @since 0.71
 *
 * @global string $currentday  The day of the current post in the loop.
 * @global string $previousday The day of the previous post in the loop.
 *
 * @param string $format Optional. PHP date format. Defaults to the 'date_format' option.
 * @param string $before Optional. Output before the date. Default empty.
 * @param string $after  Optional. Output after the date. Default empty.
 * @param bool   $echo   Optional. Whether to echo the date or return it. Default true.
 * @return string|void String if retrieving.
 */
function the_date($format = '', $before = '', $after = '', $echo = true)
{
    global $currentday, $previousday;
    $the_date = '';
    if (is_new_day()) {
        $the_date = $before . get_the_date($format) . $after;
        $previousday = $currentday;
    }
    /**
     * Filters the date a post was published for display.
     *
     * @since 0.71
     *
     * @param string $the_date The formatted date string.
     * @param string $format   PHP date format.
     * @param string $before   HTML output before the date.
     * @param string $after    HTML output after the date.
     */
    $the_date = apply_filters('the_date', $the_date, $format, $before, $after);
    if ($echo) {
        echo $the_date;
    } else {
        return $the_date;
    }
}

WordPress Version: 5.5

/**
 * Display or Retrieve the date the current post was written (once per date)
 *
 * Will only output the date if the current post's date is different from the
 * previous one output.
 *
 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
 * function is called several times for each post.
 *
 * HTML output can be filtered with 'the_date'.
 * Date string output can be filtered with 'get_the_date'.
 *
 * @since 0.71
 *
 * @global string $currentday  The day of the current post in the loop.
 * @global string $previousday The day of the previous post in the loop.
 *
 * @param string $format Optional. PHP date format defaults to the date_format option if not specified.
 * @param string $before Optional. Output before the date.
 * @param string $after  Optional. Output after the date.
 * @param bool   $echo   Optional. Whether to echo the date or return it. Default true.
 * @return string|void String if retrieving.
 */
function the_date($format = '', $before = '', $after = '', $echo = true)
{
    global $currentday, $previousday;
    $the_date = '';
    if (is_new_day()) {
        $the_date = $before . get_the_date($format) . $after;
        $previousday = $currentday;
    }
    /**
     * Filters the date a post was published for display.
     *
     * @since 0.71
     *
     * @param string $the_date The formatted date string.
     * @param string $format   PHP date format. Defaults to 'date_format' option
     *                         if not specified.
     * @param string $before   HTML output before the date.
     * @param string $after    HTML output after the date.
     */
    $the_date = apply_filters('the_date', $the_date, $format, $before, $after);
    if ($echo) {
        echo $the_date;
    } else {
        return $the_date;
    }
}

WordPress Version: 5.4

/**
 * Display or Retrieve the date the current post was written (once per date)
 *
 * Will only output the date if the current post's date is different from the
 * previous one output.
 *
 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
 * function is called several times for each post.
 *
 * HTML output can be filtered with 'the_date'.
 * Date string output can be filtered with 'get_the_date'.
 *
 * @since 0.71
 *
 * @global string $currentday  The day of the current post in the loop.
 * @global string $previousday The day of the previous post in the loop.
 *
 * @param string $format Optional. PHP date format defaults to the date_format option if not specified.
 * @param string $before Optional. Output before the date.
 * @param string $after  Optional. Output after the date.
 * @param bool   $echo   Optional, default is display. Whether to echo the date or return it.
 * @return string|void String if retrieving.
 */
function the_date($format = '', $before = '', $after = '', $echo = true)
{
    global $currentday, $previousday;
    $the_date = '';
    if (is_new_day()) {
        $the_date = $before . get_the_date($format) . $after;
        $previousday = $currentday;
    }
    /**
     * Filters the date a post was published for display.
     *
     * @since 0.71
     *
     * @param string $the_date The formatted date string.
     * @param string $format   PHP date format. Defaults to 'date_format' option
     *                         if not specified.
     * @param string $before   HTML output before the date.
     * @param string $after    HTML output after the date.
     */
    $the_date = apply_filters('the_date', $the_date, $format, $before, $after);
    if ($echo) {
        echo $the_date;
    } else {
        return $the_date;
    }
}

WordPress Version: 5.3

/**
 * Display or Retrieve the date the current post was written (once per date)
 *
 * Will only output the date if the current post's date is different from the
 * previous one output.
 *
 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
 * function is called several times for each post.
 *
 * HTML output can be filtered with 'the_date'.
 * Date string output can be filtered with 'get_the_date'.
 *
 * @since 0.71
 *
 * @global string $currentday  The day of the current post in the loop.
 * @global string $previousday The day of the previous post in the loop.
 *
 * @param string $d      Optional. PHP date format defaults to the date_format option if not specified.
 * @param string $before Optional. Output before the date.
 * @param string $after  Optional. Output after the date.
 * @param bool   $echo   Optional, default is display. Whether to echo the date or return it.
 * @return string|void String if retrieving.
 */
function the_date($d = '', $before = '', $after = '', $echo = true)
{
    global $currentday, $previousday;
    $the_date = '';
    if (is_new_day()) {
        $the_date = $before . get_the_date($d) . $after;
        $previousday = $currentday;
    }
    /**
     * Filters the date a post was published for display.
     *
     * @since 0.71
     *
     * @param string $the_date The formatted date string.
     * @param string $d        PHP date format. Defaults to 'date_format' option
     *                         if not specified.
     * @param string $before   HTML output before the date.
     * @param string $after    HTML output after the date.
     */
    $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
    if ($echo) {
        echo $the_date;
    } else {
        return $the_date;
    }
}

WordPress Version: 4.6

/**
 * Display or Retrieve the date the current post was written (once per date)
 *
 * Will only output the date if the current post's date is different from the
 * previous one output.
 *
 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
 * function is called several times for each post.
 *
 * HTML output can be filtered with 'the_date'.
 * Date string output can be filtered with 'get_the_date'.
 *
 * @since 0.71
 *
 * @global string|int|bool $currentday
 * @global string|int|bool $previousday
 *
 * @param string $d      Optional. PHP date format defaults to the date_format option if not specified.
 * @param string $before Optional. Output before the date.
 * @param string $after  Optional. Output after the date.
 * @param bool   $echo   Optional, default is display. Whether to echo the date or return it.
 * @return string|void String if retrieving.
 */
function the_date($d = '', $before = '', $after = '', $echo = true)
{
    global $currentday, $previousday;
    if (is_new_day()) {
        $the_date = $before . get_the_date($d) . $after;
        $previousday = $currentday;
        /**
         * Filters the date a post was published for display.
         *
         * @since 0.71
         *
         * @param string $the_date The formatted date string.
         * @param string $d        PHP date format. Defaults to 'date_format' option
         *                         if not specified.
         * @param string $before   HTML output before the date.
         * @param string $after    HTML output after the date.
         */
        $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
        if ($echo) {
            echo $the_date;
        } else {
            return $the_date;
        }
    }
}

WordPress Version: 4.4

/**
 * Display or Retrieve the date the current post was written (once per date)
 *
 * Will only output the date if the current post's date is different from the
 * previous one output.
 *
 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
 * function is called several times for each post.
 *
 * HTML output can be filtered with 'the_date'.
 * Date string output can be filtered with 'get_the_date'.
 *
 * @since 0.71
 *
 * @global string|int|bool $currentday
 * @global string|int|bool $previousday
 *
 * @param string $d      Optional. PHP date format defaults to the date_format option if not specified.
 * @param string $before Optional. Output before the date.
 * @param string $after  Optional. Output after the date.
 * @param bool   $echo   Optional, default is display. Whether to echo the date or return it.
 * @return string|void String if retrieving.
 */
function the_date($d = '', $before = '', $after = '', $echo = true)
{
    global $currentday, $previousday;
    if (is_new_day()) {
        $the_date = $before . get_the_date($d) . $after;
        $previousday = $currentday;
        /**
         * Filter the date a post was published for display.
         *
         * @since 0.71
         *
         * @param string $the_date The formatted date string.
         * @param string $d        PHP date format. Defaults to 'date_format' option
         *                         if not specified.
         * @param string $before   HTML output before the date.
         * @param string $after    HTML output after the date.
         */
        $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
        if ($echo) {
            echo $the_date;
        } else {
            return $the_date;
        }
    }
}

WordPress Version: 4.3

/**
 * Display or Retrieve the date the current post was written (once per date)
 *
 * Will only output the date if the current post's date is different from the
 * previous one output.
 *
 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
 * function is called several times for each post.
 *
 * HTML output can be filtered with 'the_date'.
 * Date string output can be filtered with 'get_the_date'.
 *
 * @since 0.71
 *
 * @global string|int|bool $currentday
 * @global string|int|bool $previousday
 *
 * @param string $d      Optional. PHP date format defaults to the date_format option if not specified.
 * @param string $before Optional. Output before the date.
 * @param string $after  Optional. Output after the date.
 * @param bool   $echo   Optional, default is display. Whether to echo the date or return it.
 * @return string|void String if retrieving.
 */
function the_date($d = '', $before = '', $after = '', $echo = true)
{
    global $currentday, $previousday;
    if ($currentday != $previousday) {
        $the_date = $before . get_the_date($d) . $after;
        $previousday = $currentday;
        /**
         * Filter the date a post was published for display.
         *
         * @since 0.71
         *
         * @param string $the_date The formatted date string.
         * @param string $d        PHP date format. Defaults to 'date_format' option
         *                         if not specified.
         * @param string $before   HTML output before the date.
         * @param string $after    HTML output after the date.
         */
        $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
        if ($echo) {
            echo $the_date;
        } else {
            return $the_date;
        }
    }
}

WordPress Version: 4.1

/**
 * Display or Retrieve the date the current post was written (once per date)
 *
 * Will only output the date if the current post's date is different from the
 * previous one output.
 *
 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
 * function is called several times for each post.
 *
 * HTML output can be filtered with 'the_date'.
 * Date string output can be filtered with 'get_the_date'.
 *
 * @since 0.71
 *
 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
 * @param string $before Optional. Output before the date.
 * @param string $after Optional. Output after the date.
 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
 * @return string|null Null if displaying, string if retrieving.
 */
function the_date($d = '', $before = '', $after = '', $echo = true)
{
    global $currentday, $previousday;
    if ($currentday != $previousday) {
        $the_date = $before . get_the_date($d) . $after;
        $previousday = $currentday;
        /**
         * Filter the date a post was published for display.
         *
         * @since 0.71
         *
         * @param string $the_date The formatted date string.
         * @param string $d        PHP date format. Defaults to 'date_format' option
         *                         if not specified.
         * @param string $before   HTML output before the date.
         * @param string $after    HTML output after the date.
         */
        $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
        if ($echo) {
            echo $the_date;
        } else {
            return $the_date;
        }
    }
    return null;
}

WordPress Version: 3.9

/**
 * Display or Retrieve the date the current post was written (once per date)
 *
 * Will only output the date if the current post's date is different from the
 * previous one output.
 *
 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
 * function is called several times for each post.
 *
 * HTML output can be filtered with 'the_date'.
 * Date string output can be filtered with 'get_the_date'.
 *
 * @since 0.71
 *
 * @uses get_the_date()
 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
 * @param string $before Optional. Output before the date.
 * @param string $after Optional. Output after the date.
 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
 * @return string|null Null if displaying, string if retrieving.
 */
function the_date($d = '', $before = '', $after = '', $echo = true)
{
    global $currentday, $previousday;
    if ($currentday != $previousday) {
        $the_date = $before . get_the_date($d) . $after;
        $previousday = $currentday;
        /**
         * Filter the date a post was published for display.
         *
         * @since 0.71
         *
         * @param string $the_date The formatted date string.
         * @param string $d        PHP date format. Defaults to 'date_format' option
         *                         if not specified.
         * @param string $before   HTML output before the date.
         * @param string $after    HTML output after the date.
         */
        $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
        if ($echo) {
            echo $the_date;
        } else {
            return $the_date;
        }
    }
    return null;
}

WordPress Version: 3.7

/**
 * Display or Retrieve the date the current $post was written (once per date)
 *
 * Will only output the date if the current post's date is different from the
 * previous one output.
 *
 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
 * function is called several times for each post.
 *
 * HTML output can be filtered with 'the_date'.
 * Date string output can be filtered with 'get_the_date'.
 *
 * @since 0.71
 * @uses get_the_date()
 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
 * @param string $before Optional. Output before the date.
 * @param string $after Optional. Output after the date.
 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
 * @return string|null Null if displaying, string if retrieving.
 */
function the_date($d = '', $before = '', $after = '', $echo = true)
{
    global $currentday, $previousday;
    $the_date = '';
    if ($currentday != $previousday) {
        $the_date .= $before;
        $the_date .= get_the_date($d);
        $the_date .= $after;
        $previousday = $currentday;
        $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
        if ($echo) {
            echo $the_date;
        } else {
            return $the_date;
        }
    }
    return null;
}