MySQL——时间、字符串、时间戳相互转换


一、时间转字符串

  select data_format(now(),'%Y-%m-%d %H:%i:%s');

二、时间转时间戳

  select unix_timestamp(now());

三、字符串转时间

  select str_to_data('2018-05-02','%Y-%m-%d %H:%i:%s')

四、字符串转时间戳

  select unix_)timestamp('2018-05-02')

五、时间戳转时间

  select from_unixtime(1525263383)

六、时间戳转字符串

  select from_unixtime(1525263383,'%Y-%m')


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM