Whats the way to format a date after using get_posts()

I see that theres no way to get a formatted date from a function like

echo get_the_date($post->ID, 'd M Y');

get_the_date only works with the current $post. If I used get_posts() how can I format the date. With pure PHP I can do something like …

Read More
echo DateTime::createFromFormat('Y-m-d h:i:s', $cp->post_date)->format('d M Y');

but its abit long, and I don’t know if there’s a need to actually create a DateTime object, perhaps its a waste of resources?

Related posts

Leave a Reply

1 comment