This simple function will return the date and time of the last update to your WordPress website.
Paste this code in the functions.php
file for your theme:
function get_last_update_date($format = 'r') { global $wpdb; $timestamp = $wpdb->get_var( "SELECT post_modified FROM $wpdb->posts ORDER BY post_modified DESC LIMIT 1" ); return date($format, strtotime( $timestamp )); }
Call the function with whatever date format you want, and voila!
HI! Wouldn’t it be faster/less memory dependent if you put a LIMIT 1 in the query?
Yes, that’s a good suggestion. Even if you’re only looking for a single result, adding LIMIT 1 can make a big impact – I’ll update the post!