get_comment_date的使用方法

  get_comment_date函数是检索当前评论的评论日期。

get_comment_date( string $format = '', int|WP_Comment $comment_ID )

参数
$格式
(字符串) (可选) PHP日期格式。默认为'date_format'选项。

默认值: ''

$ comment_ID
(int | WP_Comment) (可选) WP_Comment或要获取其日期的注释的ID。当前默认默认评论。

  

  基础用法

$d = "l, F jS, Y";
$comment_date = get_comment_date( $d, $comment_ID );
echo $comment_date;
 
// This will output something similar to "Saturday, November 6th, 2010". 

  调用不同的时间格式

// Prints something like: Monday 8th of August 2005
echo get_comment_date( 'l jS \of F Y' );
 
// Prints something like: Mon Mar 8 2012
echo get_comment_date( 'D M j Y' );
 
// Prints something like 07/08/2017 (dd/mm/yyyy)
echo get_comment_date( 'd\/m\/Y' );
posted @ 2021-04-26 10:25  ytkah  阅读(167)  评论(0编辑  收藏  举报
网址导航 gg N / G Sitemap

部分内容来源于网络,如有版权问题请联系删除