Anda mungkin ingin menggunakan UNIX_TIMESTAMP()
fungsi di SELECT
. Anda pernyataan, seperti pada contoh berikut:
CREATE TABLE test_tb (`timestamp` TIMESTAMP DEFAULT NOW());
INSERT INTO test_tb VALUES (DEFAULT);
SELECT UNIX_TIMESTAMP(`timestamp`) epoch, `timestamp` FROM test_tb;
+------------+---------------------+
| epoch | timestamp |
+------------+---------------------+
| 1281834891 | 2010-08-15 03:14:51 |
+------------+---------------------+
1 row in set (0.00 sec)