소스 분석중에 unix_timestamp 이것이 나와 먼가 했다. 분명 어디서 본듯한...하지만..생각이 나질 않는..그런 존재 ㅎㄷㄷ

select UNIX_TIMESTAMP('1970-01-01') 이렇게 하면 0이 나온다. 1970년 01월 01일부터 1초마다 1씩 증가해 현재시간 2009년 03월 10일 9시 29분으로 타임스팸프 값은 1236709813이다. 올해 발렌타인 2월 14일 아침 8시반에는 1234567890이 되었다는 점ㅋㅋ

mysql에서 사용법은 아래 와 같습니다.

mysql> select date_format( now() , "%Y%m%d-%H%i%S");
+---------------------------------------+
| date_format( now() , "%Y%m%d-%H%i%S") |
+---------------------------------------+
| 20050108-114845                       |
+---------------------------------------+

 

mysql> select date_format( 34252524323432 , "%Y%m%d-%H%i%S");
+------------------------------------------------+
| date_format( 34252524323432 , "%Y%m%d-%H%i%S") |
+------------------------------------------------+
| NULL                                           |
+------------------------------------------------+
1 row in set, 1 warning (0.00 sec)

 

mysql> select unix_timestamp();
+------------------+
| unix_timestamp() |
+------------------+
|       1105152570 |
+------------------+

 


mysql> select date_format( unix_timestamp() , "%Y%m%d-%H%i%S");
+--------------------------------------------------+
| date_format( unix_timestamp() , "%Y%m%d-%H%i%S") |
+--------------------------------------------------+
| NULL                                             |
+--------------------------------------------------+
1 row in set, 1 warning (0.00 sec)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

mysql> select from_unixtime(now());
+----------------------+
| from_unixtime(now()) |
+----------------------+
| 2008-01-20 06:26:44  |
+----------------------+

 

mysql>  select from_unixtime(1103152232);
+---------------------------+
| from_unixtime(1103152232) |
+---------------------------+
| 2004-12-16 08:10:32       |
+---------------------------+

 


mysql> select from_unixtime(1103152232, "%Y%m%d-%H%i%S");
+--------------------------------------------+
| from_unixtime(1103152232, "%Y%m%d-%H%i%S") |
+--------------------------------------------+
| 20041216-081032                            |
+--------------------------------------------+

 

mysql>  select from_unixtime(1103152232, "%Y-%m-%d %H:%i:%S");
+------------------------------------------------+
| from_unixtime(1103152232, "%Y-%m-%d %H:%i:%S") |
+------------------------------------------------+
| 2004-12-16 08:10:32                            |
+------------------------------------------------+

mysql>

Posted by Finebe
,