how to change “published date” format on edit.php (Posts page)?

  1. Add a column to the post edit screen and format the date however you like.

  2. Remove the default Date column.

EDIT here’s the code to put inside your theme’s functions.php file:

EDIT 2 added additional code to add publish status and make the column sortable, this should now be a complete copy of the original date column.

function my_custom_columns( $columns ) {
  unset( $columns['date'] );
  $columns['mydate'] = 'My Custom Date';
  return $columns;
}

function my_format_column( $column_name , $post_id ) {
    if($column_name == 'mydate'){
        echo get_the_time( 'l, F j, Y', $post_id )."<br>".get_post_status( $post_id );
    }
}

function my_column_register_sortable( $columns ) {
    $columns['mydate'] = 'mydate';
    return $columns;
}

function my_column_orderby( $vars ) {
    if ( isset( $vars['orderby'] ) && 'mydate' == $vars['orderby'] ) {
        $vars = array_merge( $vars, array(
            'orderby' => 'date'
        ) );
    }
    return $vars;
}

function my_column_init() {
  add_filter( 'manage_posts_columns' , 'my_custom_columns' );
  add_action( 'manage_posts_custom_column' , 'my_format_column' , 10 , 2 );
  add_filter( 'manage_edit-post_sortable_columns', 'my_column_register_sortable' );
  add_filter( 'request', 'my_column_orderby' );
}
add_action( 'admin_init' , 'my_column_init' );

Thanks to Scribu for his tutorial on sortable columns

Leave a Comment