MySQL FROM_UNIXTIME

MySQL FROM_UNIXTIME is one of the Date Functions used to convert or represent the UNIX_TIMESTAMP value in YYYY-MM-DD-HH-MM-SS or YYYYMMDDHHMMSS formats. The basic syntax of the MySQL FROM_UNIXTIME Function 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 method example, then the return value will be in that format.

MySQL FROM_UNIXTIME function Example

The following example helps you understand the use of the From_Unixtime method.

SELECT FROM_UNIXTIME(100);

SELECT FROM_UNIXTIME(1551073923);

SELECT FROM_UNIXTIME(1551033000);
MySQL FROM_UNIXTIME Function Example 1

Let us see another example of the FROM_UNIXTIME method. Here, we are using the UNIX_TIMESTAMP along with this one. It helps you understand how the output of one MySQL method 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);
FROM_UNIXTIME Function 2