Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the exact date and time when mysql database table last updated?

Tags:

php

mysql

Hi everyone I am new in web development and I am suffering from a problem to get date and time when mysql database table last updated because I have to show it on my web page. I am getting the last updated date correctly but not correct time please help me.

 <?php

    $sql = "SHOW TABLE STATUS FROM MydatabaseName LIKE 'TableName'";
    $tableStatus = mysql_query($sql);

while ($array = mysql_fetch_array($tableStatus)) {
          $updatetime = $array['Update_time'];

          $datetime = new DateTime($updatetime);
          echo $updatetime ;
     }

 ?>
like image 751
Pankaj Gupta Avatar asked Nov 08 '22 16:11

Pankaj Gupta


1 Answers

If this could help you

SELECT UPDATE_TIME
FROM   information_schema.tables
WHERE  TABLE_SCHEMA = 'dbname'
AND TABLE_NAME = 'tabname'

How can I tell when a MySQL table was last updated?

like image 91
Ashish Avatar answered Nov 14 '22 22:11

Ashish