4 posts by 3 authors in: Forums > CMS Builder
Last Post: January 16, 2018   (RSS)

Hi

I have been asked to add a notification to a website that provides the last time the database was updated and what to what section. It would read something like:

[Section Name] last updated: Monday 1 January.

This forum has the function to do this, but I am not using the forum plugin, this is just for a standard cmsb installation.

Thanks

Hi Jeff, 

Just saw this old post, if you've still got that task in your queue you can do it with this custom code.  Just change the table name: 

// get last updated time for a table
$table = getTableNameWithPrefix("articles");
$firstResult = mysql_get_query("SELECT updatedDate FROM `$table` ORDER BY updatedDate DESC LIMIT 1");
$lastUpdated = $firstResult['updatedDate'];
$lastUpdated = date("Y-m-d H:i:s", strtotime($lastUpdated)); // date formatting: http://php.net/date
print $lastUpdated;

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

Thanks Dave

That's got me on the right track, but it's not quite what I was after. Your solution shows me how to display the last time Articles was updated. But let's say I have two tables: Articles and News. How would I display the name and date of the most recently updated table? 

For example: if Articles was updated 1 January and News was updated 2nd January, my website would display:

Latest Update: News, 2 January 2018