Home > Database > Mysql Tutorial > body text

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

WBOY
Release: 2023-08-25 15:13:09
forward
632 people have browsed it

在时间戳值中添加微秒以将其转换为整数时,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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!