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
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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;
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0