当前浏览:首页 / WordPress函数 / get_comment_time()

get_comment_time( string $format = '', bool $gmt = false, bool $translate = true )

检索当前评论的时间

comment 评论more...

timemore...


参数

$format

(string) (可选) PHP时间格式,默认为“time_format”选项。

默认值: ''

$gmt

(bool) (可选) 是否使用GMT日期。

默认值: false

$translate

(bool) (可选) 是否转换时间(用于feed)。

默认值: true


返回

(string) 格式化的时间。



源码

查看源码 官方文档


更新日志

版本描述
1.5.0开始引入

使用示例

  • 示例1

    不同时间格式的示例

    // Prints something like: 03:08:46 PM
    echo get_comment_time( 'h:i:s A' );
    
    // Prints something like: 3:08:46 pm
    echo get_comment_time( 'g:i:s a' );
    
    // Prints 24 hour time, something like: 0800
    echo get_comment_time( 'Hi' );
    
    // Prints 24 hour time, something like: 800
    echo get_comment_time( 'Gi' );