Home  >  Article  >  Database  >  What does MySQL return when adding microseconds to a timestamp value to convert it to an integer?

What does MySQL return when adding microseconds to a timestamp value to convert it to an integer?

WBOY
WBOYforward
2023-08-25 15:13:09607browse

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

As we all know, the value of timestamp can be converted into seconds with the help of UNIX_TIMESTAMP() function. MySQL ignores microseconds added to the timestamp value because the value of UNIX_TIMESTAMP is only 10 digits long.

Example

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)

The query above shows that the output remains the same even after adding a 6-digit microsecond value.

The above is the detailed content of What does MySQL return when adding microseconds to a timestamp value to convert it to an integer?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete