MYSQL

애니위즈 2011. 3. 31. 18:29

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 |
+------------------------------------------------+