mysql时间戳

时间戳:从1970/1/1 8:0:0到现在或者指定时间的秒数。

msyql中UNIX_TIMESTAMP()取传入参数的时间戳,为空时为当前的时间戳。


mysql> select UNIX_TIMESTAMP();
+------------------+
| UNIX_TIMESTAMP() |
+------------------+
|       1473662965 |
+------------------+
1 row in set (0.00 sec)

mysql> SELECT UNIX_TIMESTAMP('2016-09-08 11:11:11');
+---------------------------------------+
| UNIX_TIMESTAMP('2016-09-08 11:11:11') |
+---------------------------------------+
|                            1473304271 |
+---------------------------------------+
1 row in set (0.00 sec)

FROM_UNIXTIME格式化mysql时间戳

mysql> SELECT FROM_UNIXTIME(1473304271);
+---------------------------+
| FROM_UNIXTIME(1473304271) |
+---------------------------+
| 2016-09-08 11:11:11       |
+---------------------------+
1 row in set (0.00 sec)

mysql> SELECT FROM_UNIXTIME('');
+----------------------------+
| FROM_UNIXTIME('')          |
+----------------------------+
| 1970-01-01 08:00:00.000000 |
+----------------------------+
1 row in set, 1 warning (0.00 sec)


该链接能算出时间戳

http://tool.chinaz.com/Tools/unixtime.aspx?jdfwkey=493q

你可能感兴趣的:(数据库)