Skip to content

Administration: Fix date column showing post time instead of modified time #9501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions src/wp-admin/includes/class-wp-posts-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -1196,16 +1196,32 @@ public function column_date( $post ) {
$t_time = __( 'Unpublished' );
$time_diff = 0;
} else {
$t_time = sprintf(
/* translators: 1: Post date, 2: Post time. */
__( '%1$s at %2$s' ),
/* translators: Post date format. See https://www.php.net/manual/datetime.format.php */
get_the_time( __( 'Y/m/d' ), $post ),
/* translators: Post time format. See https://www.php.net/manual/datetime.format.php */
get_the_time( __( 'g:i a' ), $post )
);
// Use modified time for unpublished posts to match "Last Modified" status label
$use_modified_time = ! in_array( $post->post_status, array( 'publish', 'future' ), true );

if ( $use_modified_time ) {
$t_time = sprintf(
/* translators: 1: Modified date, 2: Modified time. */
__( '%1$s at %2$s' ),
/* translators: Modified date format. See https://www.php.net/manual/datetime.format.php */
get_the_modified_time( __( 'Y/m/d' ), $post ),
/* translators: Modified time format. See https://www.php.net/manual/datetime.format.php */
get_the_modified_time( __( 'g:i a' ), $post )
);
$time = get_post_modified_time( 'U', false, $post );
} else {
$t_time = sprintf(
/* translators: 1: Post date, 2: Post time. */
__( '%1$s at %2$s' ),
/* translators: Post date format. See https://www.php.net/manual/datetime.format.php */
get_the_time( __( 'Y/m/d' ), $post ),
/* translators: Post time format. See https://www.php.net/manual/datetime.format.php */
get_the_time( __( 'g:i a' ), $post )
);

$time = get_post_timestamp( $post );
}

$time = get_post_timestamp( $post );
$time_diff = time() - $time;
}

Expand Down
Loading