The get_lastcommentmodified() WordPress PHP function retrieves the date the last comment was modified.
Usage
get_lastcommentmodified($timezone);
Custom example:
$last_modified = get_lastcommentmodified('blog'); echo 'The last comment was modified on: ' . $last_modified;
Parameters
$timezone
(string) (Optional) – Which timezone to use in reference to ‘gmt’, ‘blog’, or ‘server’ locations. Default: ‘server’.
More information
See WordPress Developer Resources: get_lastcommentmodified()
Examples
Display last comment modified date in GMT
Retrieve and display the date when the last comment was modified in GMT timezone.
$last_modified_gmt = get_lastcommentmodified('gmt'); echo 'The last comment was modified on (GMT): ' . $last_modified_gmt;
Display last comment modified date in blog timezone
Retrieve and display the date when the last comment was modified in the blog’s timezone.
$last_modified_blog = get_lastcommentmodified('blog'); echo 'The last comment was modified on (Blog Timezone): ' . $last_modified_blog;
Display last comment modified date in server timezone
Retrieve and display the date when the last comment was modified in the server’s timezone.
$last_modified_server = get_lastcommentmodified('server'); echo 'The last comment was modified on (Server Timezone): ' . $last_modified_server;
Display last comment modified date in a formatted string
Retrieve the last comment modified date and display it in a formatted string.
$last_modified = get_lastcommentmodified('blog'); $formatted_date = date('F j, Y, g:i a', strtotime($last_modified)); echo 'The last comment was modified on: ' . $formatted_date;
Display a message if no comments have been modified
Check if there is a last comment modified date, and display a message if no comments have been modified.
$last_modified = get_lastcommentmodified('blog'); if ($last_modified) { echo 'The last comment was modified on: ' . $last_modified; } else { echo 'No comments have been modified.'; }