将时间戳值增加微秒以将其转换为整数,MySQL将返回什么?

2023年12月19日11:58:48

借助UNIX_TIMESTAMP()函数,可以将timestamp的值转换为秒数。MySQL将忽略添加到timestamp值中的微秒,因为UNIX_TIMESTAMP的值只有10位数字。

示例

mysql> SELECT UNIX_TIMESTAMP('2017-10-22 04:05:36')AS 'Total Number of Seconds';
+-------------------------+
| Total Number of Seconds |
+-------------------------+
| 1508625336              |
+-------------------------+
1 row in set (0.00 sec)

mysql> SELECT UNIX_TIMESTAMP('2017-10-22 04:05:36.200000')AS 'Total Number of Seconds';
+-------------------------+
| Total Number of Seconds |
+-------------------------+
| 1508625336              |
+-------------------------+
1 row in set (0.00 sec)

上面的查询显示即使将6位数的微秒值相加,输出仍然保持不变。


  • 更新时间:2023年12月19日11:58:48 ,共 607 字。