get_comment_time
Retrieve the comment time of the current comment.
Description
Returns (string)
The formatted time.
Parameters (3)
- 0. $d — Optional. (string) =>
''
- The format of the time. Default user's settings.
- 1. $gmt — Optional. (constant) =>
false
- Whether to use the GMT date. Default false.
- 2. $translate — Optional. (bool) =>
true
- Whether to translate the time (for use in feeds). Default true.
Usage
if ( !function_exists( 'get_comment_time' ) ) { require_once ABSPATH . WPINC . '/comment-template.php'; } // Optional. The format of the time. Default user's settings. $d = ''; // Optional. Whether to use the GMT date. Default false. $gmt = false; // Optional. Whether to translate the time (for use in feeds). // Default true. $translate = true; // NOTICE! Understand what this does before running. $result = get_comment_time($d, $gmt, $translate);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/comment-template.php
- function get_comment_time( $d = '', $gmt = false, $translate = true ) {
- $comment = get_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);
- /**
- * Filters 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 WP_Comment $comment The comment object.
- */
- return apply_filters( 'get_comment_time', $date, $d, $gmt, $translate, $comment );
- }