Mysql時間轉化

SELECT FROM_UNIXTIME(createtime/1000,'%Y-%m-%d %h:%i:%s') as createtime FROM src_data;    -- 16-11-10 08:07:56

SELECT FROM_UNIXTIME(createtime/1000,'%Y') as years FROM src_data;    -- 2016 年

SELECT FROM_UNIXTIME(createtime/1000,'%m') as months FROM src_data;   --  11  月

SELECT FROM_UNIXTIME(createtime/1000,'%d') as dates FROM src_data;    -- 10   日

SELECT FROM_UNIXTIME(createtime/1000,'%h') as hours FROM src_data;    -- 08   時

SELECT FROM_UNIXTIME(createtime/1000,'%i') as minth FROM src_data;    -- 07   分

SELECT FROM_UNIXTIME(createtime/1000,'%s') as seconds FROM src_data;  -- 56   秒
相關文章
相關標籤/搜索