get_comment_time()
get_comment_time( string $format = ”, bool $gmt = false…
get_comment_time( string $format = ”, bool $gmt = false, bool $translate = true )
检索当前注释的注释时间。
Retrieves the comment time of the current comment.
目录锚点:#参数#返回#源码#笔记
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $format | (string) | 可选 | 时间的格式。默认用户设置。 |
| $gmt | (bool) | 可选 | 是否使用GMT日期。 |
| $translate | (bool) | 可选 | 是否翻译时间(用于feed)。 |
返回(Return)
(string)格式化时间。
源码(Source)
/**
* Retrieve the comment time of the current comment.
*
* @since 1.5.0
*
* @global object $comment
*
* @param string $d Optional. The format of the time. Default user's settings.
* @param bool $gmt Optional. Whether to use the GMT date. Default false.
* @param bool $translate Optional. Whether to translate the time (for use in feeds).
* Default true.
* @return string The formatted time.
*/
function get_comment_time( $d = '', $gmt = false, $translate = true ) {
global $comment;
$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
if ( '' == $d )
$date = mysql2date(get_option('time_format'), $comment_date, $translate);
else
$date = mysql2date($d, $comment_date, $translate);
/**
* Filter the returned comment time.
*
* @since 1.5.0
*
* @param string|int $date The comment time, formatted as a date string or Unix timestamp.
* @param string $d Date format.
* @param bool $gmt Whether the GMT date is in use.
* @param bool $translate Whether the time is translated.
* @param object $comment The comment object.
*/
return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 1.5.0 | wp-includes/comment-template.php:1036 | 3 | 5 |
笔记(Notes)
不同时间格式的示例
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!