FROM_UNIXTIME()¶
The FROM_UNIXTIME() function returns a representation of unix_timestamp as a datetime or character string value.
Description¶
The FROM_UNIXTIME() function returns a representation of unix_timestamp as a datetime or character string value. The value returned is expressed using the session time zone. For example, the return value is in ‘YYYYY-MM-DD HH:MM:SS’ format or YYYYMMDDHHMMSS. unix_timestamp is an internal timestamp value representing seconds since 1970-01-01 00:00:00 UTC, such as produced by the UNIX_TIMESTAMP() function.
Syntax¶
> FROM_UNIXTIME(unix_timestamp[,format])
Arguments¶
Arguments |
Description |
|---|---|
format |
Optional. A format string indicating the format of the return value. |
unix_timestamp |
Required. |
Examples¶
mysql> SELECT FROM_UNIXTIME(1447430881);
+---------------------------+
| from_unixtime(1447430881) |
+---------------------------+
| 2015-11-14 00:08:01 |
+---------------------------+
1 row in set (0.00 sec)
mysql> SELECT FROM_UNIXTIME(1447430881, '%Y %D %M %h:%i:%s %x');
+-------------------------------------------------+
| from_unixtime(1447430881, %Y %D %M %h:%i:%s %x) |
+-------------------------------------------------+
| 2015 14th November 12:08:01 2015 |
+-------------------------------------------------+
1 row in set (0.00 sec)
Constraints¶
The date type supports only yyyy-mm-dd and yyyymmdd for now.