MySQL(Unix时间戳、日期)转换函数

unix_timestamp()

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

unix_timestamp(date)

mysql> select unix_timestamp('2016-05-30');
+------------------------------+
| unix_timestamp('2016-05-30') |
+------------------------------+
| 1464537600 |
+------------------------------+ mysql> select unix_timestamp('2016-05-30 14:35:21');
+---------------------------------------+
| unix_timestamp('2016-05-30 14:35:21') |
+---------------------------------------+
| 1464590121 |
+---------------------------------------+

from_unixtime(unix_timestamp)

mysql> select from_unixtime(1464590043);
+---------------------------+
| from_unixtime(1464590043) |
+---------------------------+
| 2016-05-30 14:34:03 |
+---------------------------+

from_unixtime(unix_timestamp,format)

mysql> select from_unixtime(1464590043, '%Y %D %M %h:%i:%s %x');
+---------------------------------------------------+
| from_unixtime(1464590043, '%Y %D %M %h:%i:%s %x') |
+---------------------------------------------------+
| 2016 30th May 02:34:03 2016 |
+---------------------------------------------------+
上一篇:面向对象---prototype


下一篇:HTML中三种定位relative,absolute,fixed后,盒子的百分比宽度及位置易错点