get_lastcommentmodified()
最后更新于:2021-11-26 09:14:43
get_lastcommentmodified( string$timezone=’server’)The date the last comment was modified.
参数
- $timezone
-
(string) (Optional) Which timezone to use in reference to ‘gmt’, ‘blog’, or ‘server’ locations.
Default value: ‘server’
响应
(string|false) Last comment modified date on success, false on failure.
源文件
文件: gc-includes/comment.php
function get_lastcommentmodified( $timezone = 'server' ) {
global $gcdb;
$timezone = strtolower( $timezone );
$key = "lastcommentmodified:$timezone";
$comment_modified_date = gc_cache_get( $key, 'timeinfo' );
if ( false !== $comment_modified_date ) {
return $comment_modified_date;
}
switch ( $timezone ) {
case 'gmt':
$comment_modified_date = $gcdb->get_var( "SELECT comment_date_gmt FROM $gcdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" );
break;
case 'blog':
$comment_modified_date = $gcdb->get_var( "SELECT comment_date FROM $gcdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1" );
break;
case 'server':
$add_seconds_server = gmdate( 'Z' );
$comment_modified_date = $gcdb->get_var( $gcdb->prepare( "SELECT DATE_ADD(comment_date_gmt, INTERVAL %s SECOND) FROM $gcdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT 1", $add_seconds_server ) );
break;
}
if ( $comment_modified_date ) {
gc_cache_set( $key, $comment_modified_date, 'timeinfo' );
return $comment_modified_date;
}
return false;
}