MySQL FROM_UNIXTIME is one of the Date Functions, used to convert or represents the UNIX_TIMESTAMP value in YYYY-MM-DD-HH-MM-SS or YYYYMMDDHHMMSS formats. The basic syntax of the FROM UNIX TIME Function in MySQL is as shown below:
FROM_UNIXTIME(UNIX_TIMESTAMP);
FROM_UNIXTIME(UNIX_TIMESTAMP, Format);
If you use the Format value that we specified in the DATE_FORMAT function example, then the return value will be in that format.
MySQL FROM_UNIXTIME function Example
The following example helps you understand the use of From Unix time function in MySQL.
SELECT FROM_UNIXTIME(100);
SELECT FROM_UNIXTIME(1551073923);
SELECT FROM_UNIXTIME(1551033000);
Let us see another example of the FROM_UNIXTIME function. Here, we are using the UNIX_TIMESTAMP along with this function. It helps you understand how the output of one MySQL function is becoming an input of others.
SELECT FROM_UNIXTIME(UNIX_TIMESTAMP('2015-01-31'));
SELECT UNIX_TIMESTAMP('2015-01-31'), FROM_UNIXTIME(1422642600);
SELECT UNIX_TIMESTAMP(NOW()), FROM_UNIXTIME(1552732858);