Get date of last update outside of loop

It is unclear if you are looking for the last updated post or for the last updated date for some particular post. The answer by @PatJ assumes the former. To do the latter:

$qry = new WP_Query(array('p'=>1));
var_dump($qry->posts[0]->post_modified);

Or…

$date = $wpdb->get_var("SELECT post_modified FROM {$wpdb->posts} WHERE ID = 1");
var_dump($date);

Of course you need to change the post ID to match the post you are looking for.

Leave a Comment