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)
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)
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!