PHP开发教程

MySQL unix_timestamp()函数

UNIX_TIMESTAMP(), UNIX_TIMESTAMP(date)

如果调用不带参数,返回一个UNIX时间戳(自“1970-01-0100:00:00”UTC)的一个无符号整数。如果UNIX_TIMESTAMP()被调用带有日期参数,它返回的参数为秒,自“1970-01-0100:00:00”UTC的值。日期可能是日期字符串,时间字符串,一个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)


Powered by PHP二次开发 ©2008-2017