
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
What MySQL returns if we use UNIX_TIMESTAMP() function 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)
- Related Articles
- What MySQL returns if we provide value larger than 255 as argument to MySQL CHAR() function?
- What MySQL returns if we include time components along with date component as an argument to DATEDIFF() function?
- What MySQL returns if we include date components along with time component as an argument to TIMEDIFF() function?
- What MySQL returns if the argument of QUOTE() function is NULL?
- How MySQL evaluates if we use EXISTS operator with a subquery that returns no rows?
- What MySQL EXPORT_SET() function returns if any of the argument is NULL?
- What MySQL returns if the first argument of INTERVAL() function is NULL?
- What MySQL ELT() function returns if we the index number, provided as an argument, is less than 1?
- What MySQL returns if we use NULL, as both the arguments, as one of the argument and as a separator, in CONCAT_WS() function?
- What MySQL ASCII() function returns if no parameter is provided to it?
- What MySQL CHAR_LENGTH() function returns if no parameter is provided to it?
- Convert MySQL timestamp to UNIX Timestamp?
- What happens if MySQL query returns no rows?
- How MySQL SUBSTRING_INDEX() function returns the substring if we provide the negative value of the argument ‘count’?
- What MYSQL INTERVAL() function returns if there is no bigger number in the list of arguments than the number at first argument?

Advertisements