How do I format the post date in Wordpress?

扶醉桌前 提交于 2019-12-03 06:08:12
date('n-j-Y', strtotime($recent['post_date']));

This formats it the way you want. Just replace the $recent['post_date'] in your loop with that.

Whilst Syfaro's answer is correct, best practice is to use WordPress's own function for this.

get_the_date

This defaults to the format set in the WordPress admin settings (Settings -> General), so gives a more accessible solution for future editing - particularly useful if you roll your code in multiple sites, or more importantly if you release it publicly.

Also, don't forget to escape output - check out esc_html and esc_html_e

Replace $recent["post_date"] with mysql2date('n-j-Y', $recent['post_date']).

date_i18n('l d/m/Y \à\s g:i', strtotime($item['time']))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!