Sunday, February 06, 2011

Drupal 7: Add last update date to the footer of the page

I needed to add a date of last modification of the website made in Drupal 7. I did it by enable core module PHP Filter and creating a block located a footer block region. The body of the block was as follows:
<?php
// get date of most most recent change to a node
$result = db_query('SELECT title, changed FROM {node} WHERE status=1 ORDER BY changed DESC LIMIT 1');
$node = $result->fetchObject();
$date = date('d-M-Y g:i a', $node->changed);
echo "Last update: $date";
?>