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

On edit.php, the main content is a list of posts, with columns including the published date.

I’d like to change the date format of the published date just on the admin page. In this case, I don’t want to change what the users see; I want to change what the admin sees.

Read More

I want to add the day of the week to the published/scheduled date, because I’m planning to publish “Every Tuesday, at least,” and want to make sure I’ve scheduled posts correctly.

After searching, the best route seems like it would be to create a custom field, but if there’s a more subtle way to do this, I’d prefer to not install the custom field plugin.

edit: thanks to Bainternet’s comment, I see that I already have custom fields (the option was just hidden by default). And, I see custom fields are not what I want. The data already exists; I just want to format it differently on the screen.

Related posts

Leave a Reply

2 comments

    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

  1. You can simply use the filter post_date_column_time:

    add_filter( 'post_date_column_time' , 'my_post_date_column_time' , 10 , 2 );
    
    function my_post_date_column_time( $h_time, $post ) {
        $h_time = get_post_time( 'l, F j, Y', false, $post );
        return $h_time;
    }