原本直接用 $post->post_date
输出的是 2021-11-06 09:30:24 这样的格式,但现在不需要详细时间的输出,只需要输出日期,用mysql2date函数就可以了。
code示例:
<?php
$post = get_post($post_id);
echo mysql2date('Y-m-d', $post->post_date);
?>
用 mysql2date(‘Y-m-d’, $post->post_date) 输出就是 2021-11-06 这样的格式。
参考:https://developer.wordpress.org/reference/functions/mysql2date/
原创文章,作者:陌涛,如若转载,请注明出处:https://imotao.com/6830.html