Home > Database > Mysql Tutorial > body text

What will MySQL return if we use the UNIX_TIMESTAMP() function without parameters?

PHPz
Release: 2023-09-17 12:13:02
forward
1122 people have browsed it

如果我们使用不带参数的 UNIX_TIMESTAMP() 函数,MySQL 将返回什么?

In this case, MySQL returns a Unix timestamp of the current date and time. Therefore, we can say that using no argument is the same as using NOW() as argument to the UNIX_TIMESTAMP() function.

For example, if we run a UNIX_TIMESTAMP() query with no value and using NOW() as parameter MySQL returns the same results.

mysql> Select UNIX_TIMESTAMP();
+------------------+
| UNIX_TIMESTAMP() |
+------------------+
|       1509405559 |
+------------------+
1 row in set (0.00 sec)

mysql> Select UNIX_TIMESTAMP(NOW());
+-----------------------+
| UNIX_TIMESTAMP(NOW()) |
+-----------------------+
|            1509405559 |
+-----------------------+
1 row in set (0.00 sec)
Copy after login

This can be verified by passing the results of the above query as a parameter to the FROM_UNIXTIME() function. MySQL will return the current timestamp value as shown below -

mysql> Select FROM_UNIXTIME(1509405559);
+---------------------------+
| FROM_UNIXTIME(1509405559) |
+---------------------------+
| 2017-10-31 04:49:19       |
+---------------------------+
1 row in set (0.00 sec)
Copy after login

The above is the detailed content of What will MySQL return if we use the UNIX_TIMESTAMP() function without parameters?. 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