Make WordPress Core

Opened 5 years ago

Closed 13 months ago

#48589 closed enhancement (fixed)

Twenty Twenty: Make use of wp_date instead of date_i18n

Reported by: sachyya-sachet's profile sachyya sachet Owned by: audrasjb's profile audrasjb
Milestone: 6.5 Priority: normal
Severity: normal Version: 5.3
Component: Bundled Theme Keywords: has-patch commit
Focuses: Cc:

Description

As per the new update, it is not recommended to localize time based on WP timestamp: date_i18n( DATE_RFC3339, $timestamp + $offset )

Rather use new wp_date based on Unix timestamp on Twentytwnety theme footer.php L23

Attachments (1)

48589.diff (1004 bytes) - added by sabernhardt 23 months ago.
check if wp_date() function exists before using it in the theme, or else use date_i18n()

Download all attachments as: .zip

Change History (8)

#1 @SergeyBiryukov
5 years ago

  • Summary changed from Make use of wp_date instead of date_i18n on Twentytwnety to Twenty Twenty: Make use of wp_date instead of date_i18n

#2 @joyously
5 years ago

Since wp_date is a new function, it has to be used in a way that is backward compatible. Twenty Twenty is labeled as working with WP 4.7.

#3 @ianbelanger
5 years ago

  • Keywords 2nd-opinion added

@sabernhardt
23 months ago

check if wp_date() function exists before using it in the theme, or else use date_i18n()

#4 @sabernhardt
23 months ago

  • Keywords has-patch added

I added 48589.diff in case that might improve the footer code with more recent WordPress versions.

#5 @poena
13 months ago

  • Keywords commit added; 2nd-opinion removed
  • Milestone changed from Awaiting Review to 6.5

Test Report

This report validates that the indicated patch works without issues.

Patch tested: https://core.trac.wordpress.org/raw-attachment/ticket/48589/48589.diff

Environment

  • OS: macOS 14.2.1
  • Web Server: Nginx
  • PHP: 5.6.39, 8.0.22
  • WordPress: 4.7.26 and 6.4.2.
  • Browser: Chrome
  • Theme: Twenty Twenty

Actual Results

  • ✅ No issues found, the date displays correctly.

#6 @audrasjb
13 months ago

  • Owner set to audrasjb
  • Status changed from new to accepted

Self assigning for commit consideration.

#7 @audrasjb
13 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 57301:

Twenty Twenty: Replace wp_date() with date_i18n().

Since WordPress 5.3 it is recommended to use wp_date() instead of date_i18n(). This changeset replaces the function in Twenty Twenty, with a fallback to date_i18n() for old versions of WordPress.

For more info, see https://make.wordpress.org/core/2019/09/23/date-time-improvements-wp-5-3/.

Props sachyya-sachet, joyously, sabernhardt, poena.
Fixes #48589.

Note: See TracTickets for help on using tickets.