
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MySQL UNIX_TIMESTAMP Function Behavior with No Argument
In that case, MySQL returns the Unix timestamp of the current date and time. Hence we can say that using no argument is same as using NOW() as an argument to UNIX_TIMESTAMP() function.
For example, if we run the query for UNIX_TIMESTAMP() with no value and with NOW() as an argument that MySQL returns the same result.
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)
The same can be verified by passing the result from the query above as argument to FROM_UNIXTIME() function. MySQL will return the current timestamp value as follows −
mysql> Select FROM_UNIXTIME(1509405559); +---------------------------+ | FROM_UNIXTIME(1509405559) | +---------------------------+ | 2017-10-31 04:49:19 | +---------------------------+ 1 row in set (0.00 sec)
Advertisements