修改上次评论的日期。

原型

get_lastcommentmodified( string $timezone = 'server' )

参数

$timezone (string) (Optional) 使用哪个时区来引用’gmt’,‘blog’或’server’位置。

返回值

(string|false)  最后评论修改成功日期,失败时假。

源文件

路径:wp-includes/comment.php

<?php
...
function get_lastcommentmodified( $timezone = 'server' ) {
	global $wpdb;
	$timezone = strtolower( $timezone );
	$key = "lastcommentmodified:$timezone";
	$comment_modified_date = wp_cache_get( $key, 'timeinfo' );
	if ( false !== $comment_modified_date ) {
		return $comment_modified_date;
	}
	switch ( $timezone ) {
		case 'gmt':
			$comment_modified_date = $wpdb->get_var( "SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" );
			break;
		case 'blog':
			$comment_modified_date = $wpdb->get_var( "SELECT comment_date FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" );
			break;
		case 'server':
			$add_seconds_server = date( 'Z' );
			$comment_modified_date = $wpdb->get_var( $wpdb->prepare( "SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server ) );
			break;
	}
	if ( $comment_modified_date ) {
		wp_cache_set( $key, $comment_modified_date, 'timeinfo' );
		return $comment_modified_date;
	}
	return false;
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/get_lastcommentmodified/