Change the way dates are presented in WordPress's admin view


WordPress does not respect an admin's preferred date format.

Here's how the admin list of posts looks to me:

Column with the date format separated by slashes.

I don't want it to look like that. I want it in RFC3339 format.

I know what you're thinking, just change the default date display - but that only seems to work in some areas of WordPress. It doesn't change the column-date format. Here's what mine is set to:

Settings screen showing date format set to dashes.

So that doesn't work.

Instead, you need to use the slightly obscure post_date_column_time filter

Add this to your theme's functions.php:

 PHP//  Admin view - change date format
function rfc3339_post_date_time( $time, $post ) {
    //  Modify the default time format
    $rfc3339_time = date( "Y-m-d H:i", strtotime( $post->post_date ) );
    return $rfc3339_time;
}
add_filter( "post_date_column_time", "rfc3339_post_date_time", 10, 2 );

And, hey presto, your date column will look like this: Column with the date format separated by dashes.

Obviously, you can change that code to whichever date format you prefer.


Share this post on…

One thought on “Change the way dates are presented in WordPress's admin view”

  1. says:

    Ideally, couldn't the filter you add apply the date format from the settings? Then it'd be a near-universal solution. Just a thought.
    Reply

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

Allowed HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <p> <pre> <br> <img src="" alt="" title="" srcset="">