admin管理员组

文章数量:1296492

In author archive, I want to show author registration date in the following format:

January 16, 2021

I have found this code:

$user_ID = $post->post_author;
echo the_author_meta( 'user_registered', $user_ID );

But its output format is:

2021-01-16 10:40:52

How can I strip off time and get my desired format?

I am using date format F j, Y

In author archive, I want to show author registration date in the following format:

January 16, 2021

I have found this code:

$user_ID = $post->post_author;
echo the_author_meta( 'user_registered', $user_ID );

But its output format is:

2021-01-16 10:40:52

How can I strip off time and get my desired format?

I am using date format F j, Y

Share Improve this question asked Apr 18, 2021 at 11:54 Morshed Alam SumonMorshed Alam Sumon 1571 gold badge2 silver badges7 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

How about reformat it instead of stripping?

//Get post author ID
$post_author_id = get_post_field( 'post_author', $post->ID );

//Get the registration date
$registered_date = get_the_author_meta( 'user_registered', $post_author_id );

//Convert to desired format
$output = date( 'F j, Y', strtotime($registered_date));

//Echo
echo $output;

本文标签: Display Author Registration Date