Skip to content

Instantly share code, notes, and snippets.

@RobinStamer
Created May 1, 2011 18:45
Show Gist options
  • Select an option

  • Save RobinStamer/950723 to your computer and use it in GitHub Desktop.

Select an option

Save RobinStamer/950723 to your computer and use it in GitHub Desktop.
Demo of getting seconds ago from DB
mysql> SELECT time, NOW() - time as seconds_ago FROM time_test;
+---------------------+-------------+
| time | seconds_ago |
+---------------------+-------------+
| 2011-05-01 12:43:58 | 142 |
| 2011-05-01 12:44:04 | 96 |
| 2011-05-01 12:44:24 | 76 |
+---------------------+-------------+
3 rows in set (0.00 sec)
-- CREATE TABLE time_test (time TIMESTAMP NOT NULL);
-- INSERT INTO time_test VALUES(CURRENT_TIMESTAMP());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment