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
1 Answer
Reset to default 2How 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
版权声明:本文标题:Display Author Registration Date 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741608111a2388095.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论