MYSQL中UNIX時間戳與日期的轉換

神馬和浮雲發表於2013-10-23

mysql> select FROM_UNIXTIME(1156219870,'%y-%m-%d');
+--------------------------------------+
| FROM_UNIXTIME(1156219870,'%y-%m-%d') |
+--------------------------------------+
| 06-08-22                             |
+--------------------------------------+
1 row in set (0.03 sec)

mysql> SELECT UNIX_TIMESTAMP('2006-11-04 12:23:00');
+---------------------------------------+
| UNIX_TIMESTAMP('2006-11-04 12:23:00') |
+---------------------------------------+
|                            1162614180 |
+---------------------------------------+
1 row in set (0.00 sec)

相關文章