date_i18n

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

WordPress Version: 6.2

/**
 * Retrieves the date in localized format, based on a sum of Unix timestamp and
 * timezone offset in seconds.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * Note that due to the way WP typically generates a sum of timestamp and offset
 * with `strtotime()`, it implies offset added at a _current_ time, not at the time
 * the timestamp represents. Storing such timestamps or calculating them differently
 * will lead to invalid output.
 *
 * @since 0.71
 * @since 5.3.0 Converted into a wrapper for wp_date().
 *
 * @param string   $format                Format to display the date.
 * @param int|bool $timestamp_with_offset Optional. A sum of Unix timestamp and timezone offset
 *                                        in seconds. Default false.
 * @param bool     $gmt                   Optional. Whether to use GMT timezone. Only applies
 *                                        if timestamp is not provided. Default false.
 * @return string The date, translated if locale specifies it.
 */
function date_i18n($format, $timestamp_with_offset = false, $gmt = false)
{
    $timestamp = $timestamp_with_offset;
    // If timestamp is omitted it should be current time (summed with offset, unless `$gmt` is true).
    if (!is_numeric($timestamp)) {
        // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
        $timestamp = current_time('timestamp', $gmt);
    }
    /*
     * This is a legacy implementation quirk that the returned timestamp is also with offset.
     * Ideally this function should never be used to produce a timestamp.
     */
    if ('U' === $format) {
        $date = $timestamp;
    } elseif ($gmt && false === $timestamp_with_offset) {
        // Current time in UTC.
        $date = wp_date($format, null, new DateTimeZone('UTC'));
    } elseif (false === $timestamp_with_offset) {
        // Current time in site's timezone.
        $date = wp_date($format);
    } else {
        /*
         * Timestamp with offset is typically produced by a UTC `strtotime()` call on an input without timezone.
         * This is the best attempt to reverse that operation into a local time to use.
         */
        $local_time = gmdate('Y-m-d H:i:s', $timestamp);
        $timezone = wp_timezone();
        $datetime = date_create($local_time, $timezone);
        $date = wp_date($format, $datetime->getTimestamp(), $timezone);
    }
    /**
     * Filters the date formatted based on the locale.
     *
     * @since 2.8.0
     *
     * @param string $date      Formatted date string.
     * @param string $format    Format to display the date.
     * @param int    $timestamp A sum of Unix timestamp and timezone offset in seconds.
     *                          Might be without offset if input omitted timestamp but requested GMT.
     * @param bool   $gmt       Whether to use GMT timezone. Only applies if timestamp was not provided.
     *                          Default false.
     */
    $date = apply_filters('date_i18n', $date, $format, $timestamp, $gmt);
    return $date;
}

WordPress Version: 5.9

/**
 * Retrieves the date in localized format, based on a sum of Unix timestamp and
 * timezone offset in seconds.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * Note that due to the way WP typically generates a sum of timestamp and offset
 * with `strtotime()`, it implies offset added at a _current_ time, not at the time
 * the timestamp represents. Storing such timestamps or calculating them differently
 * will lead to invalid output.
 *
 * @since 0.71
 * @since 5.3.0 Converted into a wrapper for wp_date().
 *
 * @global WP_Locale $wp_locale WordPress date and time locale object.
 *
 * @param string   $format                Format to display the date.
 * @param int|bool $timestamp_with_offset Optional. A sum of Unix timestamp and timezone offset
 *                                        in seconds. Default false.
 * @param bool     $gmt                   Optional. Whether to use GMT timezone. Only applies
 *                                        if timestamp is not provided. Default false.
 * @return string The date, translated if locale specifies it.
 */
function date_i18n($format, $timestamp_with_offset = false, $gmt = false)
{
    $timestamp = $timestamp_with_offset;
    // If timestamp is omitted it should be current time (summed with offset, unless `$gmt` is true).
    if (!is_numeric($timestamp)) {
        // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
        $timestamp = current_time('timestamp', $gmt);
    }
    /*
     * This is a legacy implementation quirk that the returned timestamp is also with offset.
     * Ideally this function should never be used to produce a timestamp.
     */
    if ('U' === $format) {
        $date = $timestamp;
    } elseif ($gmt && false === $timestamp_with_offset) {
        // Current time in UTC.
        $date = wp_date($format, null, new DateTimeZone('UTC'));
    } elseif (false === $timestamp_with_offset) {
        // Current time in site's timezone.
        $date = wp_date($format);
    } else {
        /*
         * Timestamp with offset is typically produced by a UTC `strtotime()` call on an input without timezone.
         * This is the best attempt to reverse that operation into a local time to use.
         */
        $local_time = gmdate('Y-m-d H:i:s', $timestamp);
        $timezone = wp_timezone();
        $datetime = date_create($local_time, $timezone);
        $date = wp_date($format, $datetime->getTimestamp(), $timezone);
    }
    /**
     * Filters the date formatted based on the locale.
     *
     * @since 2.8.0
     *
     * @param string $date      Formatted date string.
     * @param string $format    Format to display the date.
     * @param int    $timestamp A sum of Unix timestamp and timezone offset in seconds.
     *                          Might be without offset if input omitted timestamp but requested GMT.
     * @param bool   $gmt       Whether to use GMT timezone. Only applies if timestamp was not provided.
     *                          Default false.
     */
    $date = apply_filters('date_i18n', $date, $format, $timestamp, $gmt);
    return $date;
}

WordPress Version: 5.3

/**
 * Retrieves the date in localized format, based on a sum of Unix timestamp and
 * timezone offset in seconds.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * Note that due to the way WP typically generates a sum of timestamp and offset
 * with `strtotime()`, it implies offset added at a _current_ time, not at the time
 * the timestamp represents. Storing such timestamps or calculating them differently
 * will lead to invalid output.
 *
 * @since 0.71
 * @since 5.3.0 Converted into a wrapper for wp_date().
 *
 * @global WP_Locale $wp_locale WordPress date and time locale object.
 *
 * @param string   $format                Format to display the date.
 * @param int|bool $timestamp_with_offset Optional. A sum of Unix timestamp and timezone offset
 *                                        in seconds. Default false.
 * @param bool     $gmt                   Optional. Whether to use GMT timezone. Only applies
 *                                        if timestamp is not provided. Default false.
 * @return string The date, translated if locale specifies it.
 */
function date_i18n($format, $timestamp_with_offset = false, $gmt = false)
{
    $timestamp = $timestamp_with_offset;
    // If timestamp is omitted it should be current time (summed with offset, unless `$gmt` is true).
    if (!is_numeric($timestamp)) {
        $timestamp = current_time('timestamp', $gmt);
    }
    /*
     * This is a legacy implementation quirk that the returned timestamp is also with offset.
     * Ideally this function should never be used to produce a timestamp.
     */
    if ('U' === $format) {
        $date = $timestamp;
    } elseif ($gmt && false === $timestamp_with_offset) {
        // Current time in UTC.
        $date = wp_date($format, null, new DateTimeZone('UTC'));
    } elseif (false === $timestamp_with_offset) {
        // Current time in site's timezone.
        $date = wp_date($format);
    } else {
        /*
         * Timestamp with offset is typically produced by a UTC `strtotime()` call on an input without timezone.
         * This is the best attempt to reverse that operation into a local time to use.
         */
        $local_time = gmdate('Y-m-d H:i:s', $timestamp);
        $timezone = wp_timezone();
        $datetime = date_create($local_time, $timezone);
        $date = wp_date($format, $datetime->getTimestamp(), $timezone);
    }
    /**
     * Filters the date formatted based on the locale.
     *
     * @since 2.8.0
     *
     * @param string $date      Formatted date string.
     * @param string $format    Format to display the date.
     * @param int    $timestamp A sum of Unix timestamp and timezone offset in seconds.
     *                          Might be without offset if input omitted timestamp but requested GMT.
     * @param bool   $gmt       Whether to use GMT timezone. Only applies if timestamp was not provided.
     *                          Default false.
     */
    $date = apply_filters('date_i18n', $date, $format, $timestamp, $gmt);
    return $date;
}

WordPress Version: 5.1

/**
 * Retrieve the date in localized format, based on a sum of Unix timestamp and
 * timezone offset in seconds.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * @since 0.71
 *
 * @global WP_Locale $wp_locale
 *
 * @param string   $dateformatstring      Format to display the date.
 * @param int|bool $timestamp_with_offset Optional. A sum of Unix timestamp and timezone offset in seconds.
 *                                        Default false.
 * @param bool     $gmt                   Optional. Whether to use GMT timezone. Only applies if timestamp is
 *                                        not provided. Default false.
 *
 * @return string The date, translated if locale specifies it.
 */
function date_i18n($dateformatstring, $timestamp_with_offset = false, $gmt = false)
{
    global $wp_locale;
    $i = $timestamp_with_offset;
    if (false === $i) {
        $i = current_time('timestamp', $gmt);
    }
    /*
     * Store original value for language with untypical grammars.
     * See https://core.trac.wordpress.org/ticket/9396
     */
    $req_format = $dateformatstring;
    $dateformatstring = preg_replace('/(?<!\\\\)c/', DATE_W3C, $dateformatstring);
    $dateformatstring = preg_replace('/(?<!\\\\)r/', DATE_RFC2822, $dateformatstring);
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        $datemonth = $wp_locale->get_month(date('m', $i));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday(date('w', $i));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = $wp_locale->get_meridiem(date('a', $i));
        $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i));
        $dateformatstring = ' ' . $dateformatstring;
        $dateformatstring = preg_replace('/([^\\\\])D/', "\\1" . backslashit($dateweekday_abbrev), $dateformatstring);
        $dateformatstring = preg_replace('/([^\\\\])F/', "\\1" . backslashit($datemonth), $dateformatstring);
        $dateformatstring = preg_replace('/([^\\\\])l/', "\\1" . backslashit($dateweekday), $dateformatstring);
        $dateformatstring = preg_replace('/([^\\\\])M/', "\\1" . backslashit($datemonth_abbrev), $dateformatstring);
        $dateformatstring = preg_replace('/([^\\\\])a/', "\\1" . backslashit($datemeridiem), $dateformatstring);
        $dateformatstring = preg_replace('/([^\\\\])A/', "\\1" . backslashit($datemeridiem_capital), $dateformatstring);
        $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
    }
    $timezone_formats = array('P', 'I', 'O', 'T', 'Z', 'e');
    $timezone_formats_re = implode('|', $timezone_formats);
    if (preg_match("/{$timezone_formats_re}/", $dateformatstring)) {
        $timezone_string = get_option('timezone_string');
        if (false === $timestamp_with_offset && $gmt) {
            $timezone_string = 'UTC';
        }
        if ($timezone_string) {
            $timezone_object = timezone_open($timezone_string);
            $date_object = date_create(null, $timezone_object);
            foreach ($timezone_formats as $timezone_format) {
                if (false !== strpos($dateformatstring, $timezone_format)) {
                    $formatted = date_format($date_object, $timezone_format);
                    $dateformatstring = ' ' . $dateformatstring;
                    $dateformatstring = preg_replace("/([^\\\\]){$timezone_format}/", "\\1" . backslashit($formatted), $dateformatstring);
                    $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
                }
            }
        } else {
            $offset = get_option('gmt_offset');
            foreach ($timezone_formats as $timezone_format) {
                if ('I' === $timezone_format) {
                    continue;
                }
                if (false !== strpos($dateformatstring, $timezone_format)) {
                    if ('Z' === $timezone_format) {
                        $formatted = (string) ($offset * HOUR_IN_SECONDS);
                    } else {
                        $prefix = '';
                        $hours = (int) $offset;
                        $separator = '';
                        $minutes = abs(($offset - $hours) * 60);
                        if ('T' === $timezone_format) {
                            $prefix = 'GMT';
                        } elseif ('e' === $timezone_format || 'P' === $timezone_format) {
                            $separator = ':';
                        }
                        $formatted = sprintf('%s%+03d%s%02d', $prefix, $hours, $separator, $minutes);
                    }
                    $dateformatstring = ' ' . $dateformatstring;
                    $dateformatstring = preg_replace("/([^\\\\]){$timezone_format}/", "\\1" . backslashit($formatted), $dateformatstring);
                    $dateformatstring = substr($dateformatstring, 1);
                }
            }
        }
    }
    $j = @date($dateformatstring, $i);
    /**
     * Filters the date formatted based on the locale.
     *
     * @since 2.8.0
     *
     * @param string $j          Formatted date string.
     * @param string $req_format Format to display the date.
     * @param int    $i          A sum of Unix timestamp and timezone offset in seconds.
     * @param bool   $gmt        Whether to use GMT timezone. Only applies if timestamp was
     *                           not provided. Default false.
     */
    $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
    return $j;
}

WordPress Version: 4.7

/**
 * Retrieve the date in localized format, based on timestamp.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * @since 0.71
 *
 * @global WP_Locale $wp_locale
 *
 * @param string   $dateformatstring Format to display the date.
 * @param bool|int $unixtimestamp    Optional. Unix timestamp. Default false.
 * @param bool     $gmt              Optional. Whether to use GMT timezone. Default false.
 *
 * @return string The date, translated if locale specifies it.
 */
function date_i18n($dateformatstring, $unixtimestamp = false, $gmt = false)
{
    global $wp_locale;
    $i = $unixtimestamp;
    if (false === $i) {
        $i = current_time('timestamp', $gmt);
    }
    /*
     * Store original value for language with untypical grammars.
     * See https://core.trac.wordpress.org/ticket/9396
     */
    $req_format = $dateformatstring;
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        $datemonth = $wp_locale->get_month(date('m', $i));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday(date('w', $i));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = $wp_locale->get_meridiem(date('a', $i));
        $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i));
        $dateformatstring = ' ' . $dateformatstring;
        $dateformatstring = preg_replace("/([^\\\\])D/", "\\1" . backslashit($dateweekday_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])F/", "\\1" . backslashit($datemonth), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])l/", "\\1" . backslashit($dateweekday), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])M/", "\\1" . backslashit($datemonth_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])a/", "\\1" . backslashit($datemeridiem), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])A/", "\\1" . backslashit($datemeridiem_capital), $dateformatstring);
        $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
    }
    $timezone_formats = array('P', 'I', 'O', 'T', 'Z', 'e');
    $timezone_formats_re = implode('|', $timezone_formats);
    if (preg_match("/{$timezone_formats_re}/", $dateformatstring)) {
        $timezone_string = get_option('timezone_string');
        if ($timezone_string) {
            $timezone_object = timezone_open($timezone_string);
            $date_object = date_create(null, $timezone_object);
            foreach ($timezone_formats as $timezone_format) {
                if (false !== strpos($dateformatstring, $timezone_format)) {
                    $formatted = date_format($date_object, $timezone_format);
                    $dateformatstring = ' ' . $dateformatstring;
                    $dateformatstring = preg_replace("/([^\\\\]){$timezone_format}/", "\\1" . backslashit($formatted), $dateformatstring);
                    $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
                }
            }
        }
    }
    $j = @date($dateformatstring, $i);
    /**
     * Filters the date formatted based on the locale.
     *
     * @since 2.8.0
     *
     * @param string $j          Formatted date string.
     * @param string $req_format Format to display the date.
     * @param int    $i          Unix timestamp.
     * @param bool   $gmt        Whether to convert to GMT for time. Default false.
     */
    $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
    return $j;
}

WordPress Version: 4.6

/**
 * Retrieve the date in localized format, based on timestamp.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * @since 0.71
 *
 * @global WP_Locale $wp_locale
 *
 * @param string   $dateformatstring Format to display the date.
 * @param bool|int $unixtimestamp    Optional. Unix timestamp. Default false.
 * @param bool     $gmt              Optional. Whether to use GMT timezone. Default false.
 *
 * @return string The date, translated if locale specifies it.
 */
function date_i18n($dateformatstring, $unixtimestamp = false, $gmt = false)
{
    global $wp_locale;
    $i = $unixtimestamp;
    if (false === $i) {
        if (!$gmt) {
            $i = current_time('timestamp');
        } else {
            $i = time();
        }
        // we should not let date() interfere with our
        // specially computed timestamp
        $gmt = true;
    }
    /*
     * Store original value for language with untypical grammars.
     * See https://core.trac.wordpress.org/ticket/9396
     */
    $req_format = $dateformatstring;
    $datefunc = $gmt ? 'gmdate' : 'date';
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        $datemonth = $wp_locale->get_month($datefunc('m', $i));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday($datefunc('w', $i));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = $wp_locale->get_meridiem($datefunc('a', $i));
        $datemeridiem_capital = $wp_locale->get_meridiem($datefunc('A', $i));
        $dateformatstring = ' ' . $dateformatstring;
        $dateformatstring = preg_replace("/([^\\\\])D/", "\\1" . backslashit($dateweekday_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])F/", "\\1" . backslashit($datemonth), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])l/", "\\1" . backslashit($dateweekday), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])M/", "\\1" . backslashit($datemonth_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])a/", "\\1" . backslashit($datemeridiem), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])A/", "\\1" . backslashit($datemeridiem_capital), $dateformatstring);
        $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
    }
    $timezone_formats = array('P', 'I', 'O', 'T', 'Z', 'e');
    $timezone_formats_re = implode('|', $timezone_formats);
    if (preg_match("/{$timezone_formats_re}/", $dateformatstring)) {
        $timezone_string = get_option('timezone_string');
        if ($timezone_string) {
            $timezone_object = timezone_open($timezone_string);
            $date_object = date_create(null, $timezone_object);
            foreach ($timezone_formats as $timezone_format) {
                if (false !== strpos($dateformatstring, $timezone_format)) {
                    $formatted = date_format($date_object, $timezone_format);
                    $dateformatstring = ' ' . $dateformatstring;
                    $dateformatstring = preg_replace("/([^\\\\]){$timezone_format}/", "\\1" . backslashit($formatted), $dateformatstring);
                    $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
                }
            }
        }
    }
    $j = @$datefunc($dateformatstring, $i);
    /**
     * Filters the date formatted based on the locale.
     *
     * @since 2.8.0
     *
     * @param string $j          Formatted date string.
     * @param string $req_format Format to display the date.
     * @param int    $i          Unix timestamp.
     * @param bool   $gmt        Whether to convert to GMT for time. Default false.
     */
    $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
    return $j;
}

WordPress Version: 4.3

/**
 * Retrieve the date in localized format, based on timestamp.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * @since 0.71
 *
 * @global WP_Locale $wp_locale
 *
 * @param string   $dateformatstring Format to display the date.
 * @param bool|int $unixtimestamp    Optional. Unix timestamp. Default false.
 * @param bool     $gmt              Optional. Whether to use GMT timezone. Default false.
 *
 * @return string The date, translated if locale specifies it.
 */
function date_i18n($dateformatstring, $unixtimestamp = false, $gmt = false)
{
    global $wp_locale;
    $i = $unixtimestamp;
    if (false === $i) {
        if (!$gmt) {
            $i = current_time('timestamp');
        } else {
            $i = time();
        }
        // we should not let date() interfere with our
        // specially computed timestamp
        $gmt = true;
    }
    /*
     * Store original value for language with untypical grammars.
     * See https://core.trac.wordpress.org/ticket/9396
     */
    $req_format = $dateformatstring;
    $datefunc = $gmt ? 'gmdate' : 'date';
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        $datemonth = $wp_locale->get_month($datefunc('m', $i));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday($datefunc('w', $i));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = $wp_locale->get_meridiem($datefunc('a', $i));
        $datemeridiem_capital = $wp_locale->get_meridiem($datefunc('A', $i));
        $dateformatstring = ' ' . $dateformatstring;
        $dateformatstring = preg_replace("/([^\\\\])D/", "\\1" . backslashit($dateweekday_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])F/", "\\1" . backslashit($datemonth), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])l/", "\\1" . backslashit($dateweekday), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])M/", "\\1" . backslashit($datemonth_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])a/", "\\1" . backslashit($datemeridiem), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])A/", "\\1" . backslashit($datemeridiem_capital), $dateformatstring);
        $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
    }
    $timezone_formats = array('P', 'I', 'O', 'T', 'Z', 'e');
    $timezone_formats_re = implode('|', $timezone_formats);
    if (preg_match("/{$timezone_formats_re}/", $dateformatstring)) {
        $timezone_string = get_option('timezone_string');
        if ($timezone_string) {
            $timezone_object = timezone_open($timezone_string);
            $date_object = date_create(null, $timezone_object);
            foreach ($timezone_formats as $timezone_format) {
                if (false !== strpos($dateformatstring, $timezone_format)) {
                    $formatted = date_format($date_object, $timezone_format);
                    $dateformatstring = ' ' . $dateformatstring;
                    $dateformatstring = preg_replace("/([^\\\\]){$timezone_format}/", "\\1" . backslashit($formatted), $dateformatstring);
                    $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
                }
            }
        }
    }
    $j = @$datefunc($dateformatstring, $i);
    /**
     * Filter the date formatted based on the locale.
     *
     * @since 2.8.0
     *
     * @param string $j          Formatted date string.
     * @param string $req_format Format to display the date.
     * @param int    $i          Unix timestamp.
     * @param bool   $gmt        Whether to convert to GMT for time. Default false.
     */
    $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
    return $j;
}

WordPress Version: 4.1

/**
 * Retrieve the date in localized format, based on timestamp.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * @since 0.71
 *
 * @param string   $dateformatstring Format to display the date.
 * @param bool|int $unixtimestamp    Optional. Unix timestamp. Default false.
 * @param bool     $gmt              Optional. Whether to use GMT timezone. Default false.
 *
 * @return string The date, translated if locale specifies it.
 */
function date_i18n($dateformatstring, $unixtimestamp = false, $gmt = false)
{
    global $wp_locale;
    $i = $unixtimestamp;
    if (false === $i) {
        if (!$gmt) {
            $i = current_time('timestamp');
        } else {
            $i = time();
        }
        // we should not let date() interfere with our
        // specially computed timestamp
        $gmt = true;
    }
    /*
     * Store original value for language with untypical grammars.
     * See https://core.trac.wordpress.org/ticket/9396
     */
    $req_format = $dateformatstring;
    $datefunc = $gmt ? 'gmdate' : 'date';
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        $datemonth = $wp_locale->get_month($datefunc('m', $i));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday($datefunc('w', $i));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = $wp_locale->get_meridiem($datefunc('a', $i));
        $datemeridiem_capital = $wp_locale->get_meridiem($datefunc('A', $i));
        $dateformatstring = ' ' . $dateformatstring;
        $dateformatstring = preg_replace("/([^\\\\])D/", "\\1" . backslashit($dateweekday_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])F/", "\\1" . backslashit($datemonth), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])l/", "\\1" . backslashit($dateweekday), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])M/", "\\1" . backslashit($datemonth_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])a/", "\\1" . backslashit($datemeridiem), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])A/", "\\1" . backslashit($datemeridiem_capital), $dateformatstring);
        $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
    }
    $timezone_formats = array('P', 'I', 'O', 'T', 'Z', 'e');
    $timezone_formats_re = implode('|', $timezone_formats);
    if (preg_match("/{$timezone_formats_re}/", $dateformatstring)) {
        $timezone_string = get_option('timezone_string');
        if ($timezone_string) {
            $timezone_object = timezone_open($timezone_string);
            $date_object = date_create(null, $timezone_object);
            foreach ($timezone_formats as $timezone_format) {
                if (false !== strpos($dateformatstring, $timezone_format)) {
                    $formatted = date_format($date_object, $timezone_format);
                    $dateformatstring = ' ' . $dateformatstring;
                    $dateformatstring = preg_replace("/([^\\\\]){$timezone_format}/", "\\1" . backslashit($formatted), $dateformatstring);
                    $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
                }
            }
        }
    }
    $j = @$datefunc($dateformatstring, $i);
    /**
     * Filter the date formatted based on the locale.
     *
     * @since 2.8.0
     *
     * @param string $j          Formatted date string.
     * @param string $req_format Format to display the date.
     * @param int    $i          Unix timestamp.
     * @param bool   $gmt        Whether to convert to GMT for time. Default false.
     */
    $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
    return $j;
}

WordPress Version: 4.0

/**
 * Retrieve the date in localized format, based on timestamp.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * @since 0.71
 *
 * @param string   $dateformatstring Format to display the date.
 * @param bool|int $unixtimestamp    Optional. Unix timestamp. Default false.
 * @param bool     $gmt              Optional. Whether to use GMT timezone. Default false.
 *
 * @return string The date, translated if locale specifies it.
 */
function date_i18n($dateformatstring, $unixtimestamp = false, $gmt = false)
{
    global $wp_locale;
    $i = $unixtimestamp;
    if (false === $i) {
        if (!$gmt) {
            $i = current_time('timestamp');
        } else {
            $i = time();
        }
        // we should not let date() interfere with our
        // specially computed timestamp
        $gmt = true;
    }
    /*
     * Store original value for language with untypical grammars.
     * See http://core.trac.wordpress.org/ticket/9396
     */
    $req_format = $dateformatstring;
    $datefunc = $gmt ? 'gmdate' : 'date';
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        $datemonth = $wp_locale->get_month($datefunc('m', $i));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday($datefunc('w', $i));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = $wp_locale->get_meridiem($datefunc('a', $i));
        $datemeridiem_capital = $wp_locale->get_meridiem($datefunc('A', $i));
        $dateformatstring = ' ' . $dateformatstring;
        $dateformatstring = preg_replace("/([^\\\\])D/", "\\1" . backslashit($dateweekday_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])F/", "\\1" . backslashit($datemonth), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])l/", "\\1" . backslashit($dateweekday), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])M/", "\\1" . backslashit($datemonth_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])a/", "\\1" . backslashit($datemeridiem), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])A/", "\\1" . backslashit($datemeridiem_capital), $dateformatstring);
        $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
    }
    $timezone_formats = array('P', 'I', 'O', 'T', 'Z', 'e');
    $timezone_formats_re = implode('|', $timezone_formats);
    if (preg_match("/{$timezone_formats_re}/", $dateformatstring)) {
        $timezone_string = get_option('timezone_string');
        if ($timezone_string) {
            $timezone_object = timezone_open($timezone_string);
            $date_object = date_create(null, $timezone_object);
            foreach ($timezone_formats as $timezone_format) {
                if (false !== strpos($dateformatstring, $timezone_format)) {
                    $formatted = date_format($date_object, $timezone_format);
                    $dateformatstring = ' ' . $dateformatstring;
                    $dateformatstring = preg_replace("/([^\\\\]){$timezone_format}/", "\\1" . backslashit($formatted), $dateformatstring);
                    $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
                }
            }
        }
    }
    $j = @$datefunc($dateformatstring, $i);
    /**
     * Filter the date formatted based on the locale.
     *
     * @since 2.8.0
     *
     * @param string $j          Formatted date string.
     * @param string $req_format Format to display the date.
     * @param int    $i          Unix timestamp.
     * @param bool   $gmt        Whether to convert to GMT for time. Default false.
     */
    $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
    return $j;
}

WordPress Version: 3.9

/**
 * Retrieve the date in localized format, based on timestamp.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * @since 0.71
 *
 * @param string $dateformatstring Format to display the date.
 * @param int $unixtimestamp Optional. Unix timestamp.
 * @param bool $gmt Optional, default is false. Whether to convert to GMT for time.
 * @return string The date, translated if locale specifies it.
 */
function date_i18n($dateformatstring, $unixtimestamp = false, $gmt = false)
{
    global $wp_locale;
    $i = $unixtimestamp;
    if (false === $i) {
        if (!$gmt) {
            $i = current_time('timestamp');
        } else {
            $i = time();
        }
        // we should not let date() interfere with our
        // specially computed timestamp
        $gmt = true;
    }
    // store original value for language with untypical grammars
    // see http://core.trac.wordpress.org/ticket/9396
    $req_format = $dateformatstring;
    $datefunc = $gmt ? 'gmdate' : 'date';
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        $datemonth = $wp_locale->get_month($datefunc('m', $i));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday($datefunc('w', $i));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = $wp_locale->get_meridiem($datefunc('a', $i));
        $datemeridiem_capital = $wp_locale->get_meridiem($datefunc('A', $i));
        $dateformatstring = ' ' . $dateformatstring;
        $dateformatstring = preg_replace("/([^\\\\])D/", "\\1" . backslashit($dateweekday_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])F/", "\\1" . backslashit($datemonth), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])l/", "\\1" . backslashit($dateweekday), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])M/", "\\1" . backslashit($datemonth_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])a/", "\\1" . backslashit($datemeridiem), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])A/", "\\1" . backslashit($datemeridiem_capital), $dateformatstring);
        $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
    }
    $timezone_formats = array('P', 'I', 'O', 'T', 'Z', 'e');
    $timezone_formats_re = implode('|', $timezone_formats);
    if (preg_match("/{$timezone_formats_re}/", $dateformatstring)) {
        $timezone_string = get_option('timezone_string');
        if ($timezone_string) {
            $timezone_object = timezone_open($timezone_string);
            $date_object = date_create(null, $timezone_object);
            foreach ($timezone_formats as $timezone_format) {
                if (false !== strpos($dateformatstring, $timezone_format)) {
                    $formatted = date_format($date_object, $timezone_format);
                    $dateformatstring = ' ' . $dateformatstring;
                    $dateformatstring = preg_replace("/([^\\\\]){$timezone_format}/", "\\1" . backslashit($formatted), $dateformatstring);
                    $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
                }
            }
        }
    }
    $j = @$datefunc($dateformatstring, $i);
    /**
     * Filter the date formatted based on the locale.
     *
     * @since 2.8.0
     * 
     * @param string $j          Formatted date string.
     * @param string $req_format Format to display the date.
     * @param int    $i          Unix timestamp.
     * @param bool   $gmt        Whether to convert to GMT for time. Default false.
     */
    $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
    return $j;
}

WordPress Version: 3.7

/**
 * Retrieve the date in localized format, based on timestamp.
 *
 * If the locale specifies the locale month and weekday, then the locale will
 * take over the format for the date. If it isn't, then the date format string
 * will be used instead.
 *
 * @since 0.71
 *
 * @param string $dateformatstring Format to display the date.
 * @param int $unixtimestamp Optional. Unix timestamp.
 * @param bool $gmt Optional, default is false. Whether to convert to GMT for time.
 * @return string The date, translated if locale specifies it.
 */
function date_i18n($dateformatstring, $unixtimestamp = false, $gmt = false)
{
    global $wp_locale;
    $i = $unixtimestamp;
    if (false === $i) {
        if (!$gmt) {
            $i = current_time('timestamp');
        } else {
            $i = time();
        }
        // we should not let date() interfere with our
        // specially computed timestamp
        $gmt = true;
    }
    // store original value for language with untypical grammars
    // see http://core.trac.wordpress.org/ticket/9396
    $req_format = $dateformatstring;
    $datefunc = $gmt ? 'gmdate' : 'date';
    if (!empty($wp_locale->month) && !empty($wp_locale->weekday)) {
        $datemonth = $wp_locale->get_month($datefunc('m', $i));
        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
        $dateweekday = $wp_locale->get_weekday($datefunc('w', $i));
        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
        $datemeridiem = $wp_locale->get_meridiem($datefunc('a', $i));
        $datemeridiem_capital = $wp_locale->get_meridiem($datefunc('A', $i));
        $dateformatstring = ' ' . $dateformatstring;
        $dateformatstring = preg_replace("/([^\\\\])D/", "\\1" . backslashit($dateweekday_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])F/", "\\1" . backslashit($datemonth), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])l/", "\\1" . backslashit($dateweekday), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])M/", "\\1" . backslashit($datemonth_abbrev), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])a/", "\\1" . backslashit($datemeridiem), $dateformatstring);
        $dateformatstring = preg_replace("/([^\\\\])A/", "\\1" . backslashit($datemeridiem_capital), $dateformatstring);
        $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
    }
    $timezone_formats = array('P', 'I', 'O', 'T', 'Z', 'e');
    $timezone_formats_re = implode('|', $timezone_formats);
    if (preg_match("/{$timezone_formats_re}/", $dateformatstring)) {
        $timezone_string = get_option('timezone_string');
        if ($timezone_string) {
            $timezone_object = timezone_open($timezone_string);
            $date_object = date_create(null, $timezone_object);
            foreach ($timezone_formats as $timezone_format) {
                if (false !== strpos($dateformatstring, $timezone_format)) {
                    $formatted = date_format($date_object, $timezone_format);
                    $dateformatstring = ' ' . $dateformatstring;
                    $dateformatstring = preg_replace("/([^\\\\]){$timezone_format}/", "\\1" . backslashit($formatted), $dateformatstring);
                    $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
                }
            }
        }
    }
    $j = @$datefunc($dateformatstring, $i);
    // allow plugins to redo this entirely for languages with untypical grammars
    $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
    return $j;
}