Mysql 日期、字符串、时间戳互转
生活随笔
收集整理的這篇文章主要介紹了
Mysql 日期、字符串、时间戳互转
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
劃重點(diǎn)
常用的時(shí)間占位符 -> %Y-%m-%d %H:%i:%S
一、函數(shù)
1、date_format(date, format)
select date_format(now(),'%Y-%m-%d %H:%i:%S');# 2017-10-29 14:02:542、unix_timestamp()
select unix_timestamp(now()); # 15092574083、str_to_date(str, format)
select str_to_date('2017-10-29', '%Y-%m-%d %H:%i:%S');# 2017-10-29 00:00:004、from_unixtime(unix_timestamp, format)
select from_unixtime(1509257408); # 2017-10-29 14:10:08轉(zhuǎn)載注明出處:www.meidanlong.com 😃
總結(jié)
以上是生活随笔為你收集整理的Mysql 日期、字符串、时间戳互转的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。