What is the use of MySQL FROM_UNIXTIME() function?

MySQLMySQLi Database

MySQL FROM_UNIXTIME() function is used to return the date/datetime from a version of Unix timestamp. The format of return value would be either ‘YYYY-MM-DD HH:MM:SS’ or ‘YYYYMMDDHHMMSS.uuuuuu’ depending upon the context of the function i.e. whether the context is numeric or string.

Following is the syntax for FROM_UNIXTIME −

FROM_UNIXTIME(unix_timestamp, [format])

Here unix_timestamp is the value of Unix timestamp and format includes the format string in which we want to return the value.

Example

mysql> Select FROM_UNIXTIME(1555033470);
+---------------------------+
| FROM_UNIXTIME(1555033470) |
+---------------------------+
| 2019-04-12 07:14:30       |
+---------------------------+
1 row in set (0.00 sec)
raja
Published on 19-Feb-2018 11:40:49
Advertisements