| Title: | PHP and the MySQL datetime data type |
|---|---|
| Author: | Mark Kiehl |
| Category: | PHP |
| MySQL datetime Setup MySQL table with field/column `last_datetime` as follows: Type: timestamp Attributes: ON UPDATE CURRENT_TIMESTAMP Null: not null Default: CURRENT_TIMESTAMP Whenever the table is updated (UPDATE query), the field `last_datetime` is automatically updated. To get the records within a specified period of time (20 min), execute a select query as follows: SELECT timestampdiff(minute,`last_datetime`,now()) as `elapsedMin` FROM `tableName` WHERE timestampdiff(minute,`last_datetime`,now())<'20' |