0

In the list of posts in the 'All Posts' screen, is there a way to display both date -and- time in the Date column? If you hover over the date, the time is part of abbr tag title, but I'd like to display the time, directly. I see that I could unset the current Date column and put in a custom Date column. Just wondering if there is a simpler solution to show the time, since it's already there in the abbr tag?

2 Answers 2

4

Add this code to functions.php of your active theme:

function wpse_posts_list_date_format( $time, $post ) {
    return $post->post_date;
}
add_filter( 'post_date_column_time', 'wpse_posts_list_date_format', 10, 2 );

The callback function receives 4 parameters, but we need only 2.

1
  • I'm sure the first js solution, above, would have worked, but the post_date_column_time filter solution provided more flexibility in formatting. Instead of returning the simple $post->post_date, I used the get_post_time function to customize the date and time formats. Thank you. Commented Oct 16, 2017 at 21:15
0

You can do it with some JavaScript:

jQuery(".column-date abbr").each(function(){
    jQuery(this).html(jQuery(this).attr("title").replace(" ", "<br/>"));
    jQuery(this).removeAttr("title");
});

This will replace visible date portion with date and time and will clear the title attribute.

1
  • Please check your script. It does nicely replace date from title attribute, but it does not make title empty, afterwards.. Commented Oct 16, 2017 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.