datetime --> timestamp
+---------------------------------------+
| unix_timestamp('2017-06-27 19:06:51') |
+---------------------------------------+
| 1498561611 |
+---------------------------------------+
1 row in set (0.00 sec)
timestamp --> datetime
select unix_timestamp(now());
+-----------------------+
| unix_timestamp(now()) |
+-----------------------+
| 1498564431 |
+-----------------------+
1 row in set (0.00 sec)
select from_unixtime(1498564431,'%Y-%m-%d %H:%m:%s');
+-----------------------------------------------+
| from_unixtime(1498564431,'%Y-%m-%d %H:%m:%s') |
+-----------------------------------------------+
| 2017-06-27 19:06:51 |
+-----------------------------------------------+
1 row in set (0.00 sec)