D/MySQL

MySQL FROM_UNIXTIME()

yeon.Biju 2020. 4. 2. 12:41

MySQL 날짜함수, 시간함수

 

FROM_UNIXTIME()

   - unix_timestamp 를 날짜로 바꿔준다라고 보면 되겠다.

   - UNIX_TIMESTAMP() 와 반대의 개념

 

FROM_UNIXTIME(unix_timestamp[, format])

의 형태

 

Returns a representation of the unix_timestamp argument as a value in 'YYYY-MM-DD hh:mm:ss' or YYYYMMDDhhmmss format, depending on whether the function is used in a string or numeric context. 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.

 

 

mysql> SELECT FROM_UNIXTIME(1447430881);
+---------------------------+
| FROM_UNIXTIME(1447430881) |
+---------------------------+
| 2015-11-14 01:08:01       |
+---------------------------+
1 row in set (0.00 sec)

 

 

mysql> SELECT FROM_UNIXTIME(1447430881)+0 ;
+-----------------------------+
| FROM_UNIXTIME(1447430881)+0 |
+-----------------------------+
|              20151114010801 |
+-----------------------------+
1 row in set (0.00 sec)

mysql> SELECT FROM_UNIXTIME(1447430881, ' %Y %D %M %h:%i:%x %x');
+----------------------------------------------------+
| FROM_UNIXTIME(1447430881, ' %Y %D %M %h:%i:%x %x') |
+----------------------------------------------------+
|  2015 14th November 01:08:2015 2015                |
+----------------------------------------------------+
1 row in set (0.00 sec)