扫码一下
查看教程更方便
unix_timestamp()函数 返回 unix 时间戳。
unix_timestamp()函数语法如下
unix_timestamp()
-- 或者
unix_timestamp(date)
如果不带参数调用,此函数将返回一个 unix 时间戳(自 '1970-01-01 00:00:00' utc 以来的秒数)作为无符号整数。如果使用指定参数date,它会返回参数值作为自 '1970-01-01 00:00:00' utc 以来的秒数。date 可以是 date 字符串、datetime 字符串、timestamp 或格式为 yymmdd 或 yyyymmdd 的数字。
mysql> select unix_timestamp();
---------------------------------------------------------
| unix_timestamp() |
---------------------------------------------------------
| 882226357 |
---------------------------------------------------------
1 row in set (0.00 sec)
mysql> select unix_timestamp('1997-10-04 22:23:00');
---------------------------------------------------------
| unix_timestamp('1997-10-04 22:23:00') |
---------------------------------------------------------
| 875996580 |
---------------------------------------------------------
1 row in set (0.00 sec)