It is necessary to make the conclusion of the date of comments as follows:
- if published more than 3 hours ago, then display the date as usual
- if published less than 3 hours ago, then output
"% часов/минут/секунд назад"
Tell me how to implement.
Here are the functions:
function get_comment_date( $d = '', $comment_ID = 0 ) { $comment = get_comment( $comment_ID ); if ( '' == $d ) $date = mysql2date(get_option('date_format'), $comment->comment_date); else $date = mysql2date($d, $comment->comment_date); /** * Filter the returned comment date. * * @since 1.5.0 * * @param string|int $date Formatted date string or Unix timestamp. * @param string $d The format of the date. * @param WP_Comment $comment The comment object. */ return apply_filters( 'get_comment_date', $date, $d, $comment ); } 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); /** * 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 WP_Comment $comment The comment object. */ return apply_filters('get_comment_time', $date, $d, $gmt, $translate, $comment); } Now displayed as:

strtotimefunctionstrtotimeconvert to a Unix timestamp, add a condition if 3 hours from the current time () has not passed, then output (return) inчасов/минут/секунд назадformat. How to get this format walks a lot of examples. Example biznesguide.ru/coding/193.html - Invision