From 43f4a8646861d9b498ae2768f624a002b6d562ba Mon Sep 17 00:00:00 2001 From: "Stephen A. Bernhardt" Date: Tue, 13 Jan 2026 12:07:34 -0800 Subject: [PATCH 01/14] https://core.trac.wordpress.org/attachment/ticket/64496/64496.diff --- src/wp-admin/includes/dashboard.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index cac03b1fe3630..70da1e20a889d 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1014,7 +1014,9 @@ function wp_dashboard_recent_posts( $args ) { $time = get_the_time( 'U' ); - if ( gmdate( 'Y-m-d', $time ) === $today ) { + if ( ! is_int( $time ) ) { + $relative = ''; + } elseif ( gmdate( 'Y-m-d', $time ) === $today ) { $relative = __( 'Today' ); } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) { $relative = __( 'Tomorrow' ); @@ -1033,7 +1035,7 @@ function wp_dashboard_recent_posts( $args ) { printf( '
  • %1$s %4$s
  • ', /* translators: 1: Relative date, 2: Time. */ - sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ), + $relative ? sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ) : '', $recent_post_link, /* translators: %s: Post title. */ esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), From 102ad11721177492ee9a6f54309252c80d79b390 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 13 Jan 2026 12:15:54 -0800 Subject: [PATCH 02/14] Show underlying return value for get_the_time() if relative fails --- src/wp-admin/includes/dashboard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 70da1e20a889d..303d9298739be 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1035,7 +1035,7 @@ function wp_dashboard_recent_posts( $args ) { printf( '
  • %1$s %4$s
  • ', /* translators: 1: Relative date, 2: Time. */ - $relative ? sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ) : '', + $relative ? sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ) : get_the_time(), $recent_post_link, /* translators: %s: Post title. */ esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), From b42c718062655c9427160bf11379255cbabdb65c Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 13 Jan 2026 12:28:53 -0800 Subject: [PATCH 03/14] Use full date as fallback --- src/wp-admin/includes/dashboard.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 303d9298739be..42459a338b14f 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1015,7 +1015,8 @@ function wp_dashboard_recent_posts( $args ) { $time = get_the_time( 'U' ); if ( ! is_int( $time ) ) { - $relative = ''; + /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ + $relative = date_i18n( __( 'M jS Y' ), $time ); } elseif ( gmdate( 'Y-m-d', $time ) === $today ) { $relative = __( 'Today' ); } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) { @@ -1035,7 +1036,7 @@ function wp_dashboard_recent_posts( $args ) { printf( '
  • %1$s %4$s
  • ', /* translators: 1: Relative date, 2: Time. */ - $relative ? sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ) : get_the_time(), + sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ), $recent_post_link, /* translators: %s: Post title. */ esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), From 12530721d21a203e8ac0e2b640f24838a053fcd7 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 13 Jan 2026 12:32:08 -0800 Subject: [PATCH 04/14] Combine conditions --- src/wp-admin/includes/dashboard.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 42459a338b14f..56076ac5fc419 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1014,16 +1014,13 @@ function wp_dashboard_recent_posts( $args ) { $time = get_the_time( 'U' ); - if ( ! is_int( $time ) ) { + if ( ! is_int( $time ) || gmdate( 'Y', $time ) !== $year ) { /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ $relative = date_i18n( __( 'M jS Y' ), $time ); } elseif ( gmdate( 'Y-m-d', $time ) === $today ) { $relative = __( 'Today' ); } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) { $relative = __( 'Tomorrow' ); - } elseif ( gmdate( 'Y', $time ) !== $year ) { - /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ - $relative = date_i18n( __( 'M jS Y' ), $time ); } else { /* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/manual/datetime.format.php */ $relative = date_i18n( __( 'M jS' ), $time ); From add31fb61ce9f7132b74ef9b986ea56497ba1193 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 14 Jan 2026 13:02:11 -0800 Subject: [PATCH 05/14] Revert "Combine conditions" This reverts commit 12530721d21a203e8ac0e2b640f24838a053fcd7. --- src/wp-admin/includes/dashboard.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 56076ac5fc419..42459a338b14f 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1014,13 +1014,16 @@ function wp_dashboard_recent_posts( $args ) { $time = get_the_time( 'U' ); - if ( ! is_int( $time ) || gmdate( 'Y', $time ) !== $year ) { + if ( ! is_int( $time ) ) { /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ $relative = date_i18n( __( 'M jS Y' ), $time ); } elseif ( gmdate( 'Y-m-d', $time ) === $today ) { $relative = __( 'Today' ); } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) { $relative = __( 'Tomorrow' ); + } elseif ( gmdate( 'Y', $time ) !== $year ) { + /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ + $relative = date_i18n( __( 'M jS Y' ), $time ); } else { /* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/manual/datetime.format.php */ $relative = date_i18n( __( 'M jS' ), $time ); From 2aed48c8d59b79b6ce0941fc5d3f38369da31ef9 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 14 Jan 2026 13:02:31 -0800 Subject: [PATCH 06/14] Revert "Use full date as fallback" This reverts commit b42c718062655c9427160bf11379255cbabdb65c. --- src/wp-admin/includes/dashboard.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 42459a338b14f..303d9298739be 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1015,8 +1015,7 @@ function wp_dashboard_recent_posts( $args ) { $time = get_the_time( 'U' ); if ( ! is_int( $time ) ) { - /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ - $relative = date_i18n( __( 'M jS Y' ), $time ); + $relative = ''; } elseif ( gmdate( 'Y-m-d', $time ) === $today ) { $relative = __( 'Today' ); } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) { @@ -1036,7 +1035,7 @@ function wp_dashboard_recent_posts( $args ) { printf( '
  • %1$s %4$s
  • ', /* translators: 1: Relative date, 2: Time. */ - sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ), + $relative ? sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ) : get_the_time(), $recent_post_link, /* translators: %s: Post title. */ esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), From 0870b455ff5e602036d3c32e0d989ece11fe9513 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 14 Jan 2026 13:02:36 -0800 Subject: [PATCH 07/14] Revert "Show underlying return value for get_the_time() if relative fails" This reverts commit 102ad11721177492ee9a6f54309252c80d79b390. --- src/wp-admin/includes/dashboard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 303d9298739be..70da1e20a889d 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1035,7 +1035,7 @@ function wp_dashboard_recent_posts( $args ) { printf( '
  • %1$s %4$s
  • ', /* translators: 1: Relative date, 2: Time. */ - $relative ? sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ) : get_the_time(), + $relative ? sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ) : '', $recent_post_link, /* translators: %s: Post title. */ esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), From ede109973e9ced0878430cdb08f33f279a6f3c38 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 14 Jan 2026 13:13:02 -0800 Subject: [PATCH 08/14] Reapply "Show underlying return value for get_the_time() if relative fails" This reverts commit 0870b455ff5e602036d3c32e0d989ece11fe9513. --- src/wp-admin/includes/dashboard.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 70da1e20a889d..303d9298739be 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1035,7 +1035,7 @@ function wp_dashboard_recent_posts( $args ) { printf( '
  • %1$s %4$s
  • ', /* translators: 1: Relative date, 2: Time. */ - $relative ? sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ) : '', + $relative ? sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ) : get_the_time(), $recent_post_link, /* translators: %s: Post title. */ esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), From b8a48652f6057fe760afbe9af1b1b80abca47af9 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 14 Jan 2026 13:13:09 -0800 Subject: [PATCH 09/14] Reapply "Use full date as fallback" This reverts commit 2aed48c8d59b79b6ce0941fc5d3f38369da31ef9. --- src/wp-admin/includes/dashboard.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 303d9298739be..42459a338b14f 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1015,7 +1015,8 @@ function wp_dashboard_recent_posts( $args ) { $time = get_the_time( 'U' ); if ( ! is_int( $time ) ) { - $relative = ''; + /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ + $relative = date_i18n( __( 'M jS Y' ), $time ); } elseif ( gmdate( 'Y-m-d', $time ) === $today ) { $relative = __( 'Today' ); } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) { @@ -1035,7 +1036,7 @@ function wp_dashboard_recent_posts( $args ) { printf( '
  • %1$s %4$s
  • ', /* translators: 1: Relative date, 2: Time. */ - $relative ? sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ) : get_the_time(), + sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ), $recent_post_link, /* translators: %s: Post title. */ esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), From 96ba63b425cb8923abb718e0ca7475c4dc2fbfe4 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 14 Jan 2026 13:13:16 -0800 Subject: [PATCH 10/14] Reapply "Combine conditions" This reverts commit add31fb61ce9f7132b74ef9b986ea56497ba1193. --- src/wp-admin/includes/dashboard.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 42459a338b14f..56076ac5fc419 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1014,16 +1014,13 @@ function wp_dashboard_recent_posts( $args ) { $time = get_the_time( 'U' ); - if ( ! is_int( $time ) ) { + if ( ! is_int( $time ) || gmdate( 'Y', $time ) !== $year ) { /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ $relative = date_i18n( __( 'M jS Y' ), $time ); } elseif ( gmdate( 'Y-m-d', $time ) === $today ) { $relative = __( 'Today' ); } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) { $relative = __( 'Tomorrow' ); - } elseif ( gmdate( 'Y', $time ) !== $year ) { - /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ - $relative = date_i18n( __( 'M jS Y' ), $time ); } else { /* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/manual/datetime.format.php */ $relative = date_i18n( __( 'M jS' ), $time ); From 096cea0dbc259cfd286f1f296cd41411f04f05e1 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 14 Jan 2026 13:34:54 -0800 Subject: [PATCH 11/14] Use get_the_date() when unable to obtain relative date --- src/wp-admin/includes/dashboard.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 56076ac5fc419..44988375bf85c 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1014,13 +1014,15 @@ function wp_dashboard_recent_posts( $args ) { $time = get_the_time( 'U' ); - if ( ! is_int( $time ) || gmdate( 'Y', $time ) !== $year ) { - /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ - $relative = date_i18n( __( 'M jS Y' ), $time ); + if ( ! is_int( $time ) ) { + $relative = null; } elseif ( gmdate( 'Y-m-d', $time ) === $today ) { $relative = __( 'Today' ); } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) { $relative = __( 'Tomorrow' ); + } elseif ( gmdate( 'Y', $time ) !== $year ) { + /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ + $relative = date_i18n( __( 'M jS Y' ), $time ); } else { /* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/manual/datetime.format.php */ $relative = date_i18n( __( 'M jS' ), $time ); @@ -1033,7 +1035,7 @@ function wp_dashboard_recent_posts( $args ) { printf( '
  • %1$s %4$s
  • ', /* translators: 1: Relative date, 2: Time. */ - sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ), + sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative ?? get_the_date(), get_the_time() ), $recent_post_link, /* translators: %s: Post title. */ esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), From 958ce5cb6dfa9555746ca338d4a12651e03b4386 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 14 Jan 2026 14:08:12 -0800 Subject: [PATCH 12/14] Remove needless null coalescing Co-authored-by: Stephen A. Bernhardt --- src/wp-admin/includes/dashboard.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 44988375bf85c..c13ccd196e29f 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1015,7 +1015,7 @@ function wp_dashboard_recent_posts( $args ) { $time = get_the_time( 'U' ); if ( ! is_int( $time ) ) { - $relative = null; + $relative = get_the_date(); } elseif ( gmdate( 'Y-m-d', $time ) === $today ) { $relative = __( 'Today' ); } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) { @@ -1035,7 +1035,7 @@ function wp_dashboard_recent_posts( $args ) { printf( '
  • %1$s %4$s
  • ', /* translators: 1: Relative date, 2: Time. */ - sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative ?? get_the_date(), get_the_time() ), + sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ), $recent_post_link, /* translators: %s: Post title. */ esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), From d57f6b2139a8c6efa444a80b2622f9967f3d4a21 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 14 Jan 2026 14:09:38 -0800 Subject: [PATCH 13/14] Rename variable since not specifically relative --- src/wp-admin/includes/dashboard.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index c13ccd196e29f..0b444650f3e33 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1015,17 +1015,17 @@ function wp_dashboard_recent_posts( $args ) { $time = get_the_time( 'U' ); if ( ! is_int( $time ) ) { - $relative = get_the_date(); + $date = get_the_date(); } elseif ( gmdate( 'Y-m-d', $time ) === $today ) { - $relative = __( 'Today' ); + $date = __( 'Today' ); } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) { - $relative = __( 'Tomorrow' ); + $date = __( 'Tomorrow' ); } elseif ( gmdate( 'Y', $time ) !== $year ) { /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ - $relative = date_i18n( __( 'M jS Y' ), $time ); + $date = date_i18n( __( 'M jS Y' ), $time ); } else { /* translators: Date and time format for recent posts on the dashboard, see https://www.php.net/manual/datetime.format.php */ - $relative = date_i18n( __( 'M jS' ), $time ); + $date = date_i18n( __( 'M jS' ), $time ); } // Use the post edit link for those who can edit, the permalink otherwise. @@ -1035,7 +1035,7 @@ function wp_dashboard_recent_posts( $args ) { printf( '
  • %1$s %4$s
  • ', /* translators: 1: Relative date, 2: Time. */ - sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ), + sprintf( _x( '%1$s, %2$s', 'dashboard' ), $date, get_the_time() ), $recent_post_link, /* translators: %s: Post title. */ esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), From eb1e6d99c74294e84765583852f0a1980a71d8b8 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 14 Jan 2026 14:11:48 -0800 Subject: [PATCH 14/14] Reuse shorter date format --- src/wp-admin/includes/dashboard.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 0b444650f3e33..6cb0c881f9c94 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -1015,7 +1015,8 @@ function wp_dashboard_recent_posts( $args ) { $time = get_the_time( 'U' ); if ( ! is_int( $time ) ) { - $date = get_the_date(); + /* translators: Date and time format for recent posts on the dashboard, from a different calendar year, see https://www.php.net/manual/datetime.format.php */ + $date = get_the_date( __( 'M jS Y' ) ); } elseif ( gmdate( 'Y-m-d', $time ) === $today ) { $date = __( 'Today' ); } elseif ( gmdate( 'Y-m-d', $time ) === $tomorrow ) {