Home  >  Article  >  Backend Development  >  php转换过的时间数值如何在mysql里转换

php转换过的时间数值如何在mysql里转换

WBOY
WBOYOriginal
2016-06-13 11:48:31815browse

php转换过的时间数值怎么在mysql里转换?

通过php date函数转换过的时间存储在mysql数据库中
1391768710 
这个代表的是2014年2月7日 
我想怎么在mysql里得到这个时间呢
mysql里有怎样的时间函数,可以直接转换成时间格式的?
比如我这个字段是begintime 表名:tab_information
------解决方案--------------------
unix_timestamp  这两时间和时间戳互转的
------解决方案--------------------
select from_unixtime(1391768710)
2014-02-07 18:25:10 

select from_unixtime(1391768710, '%Y-%m-%d')
2014-02-07 

------解决方案--------------------
from_unixtime(unix_timestramp,format)这格式将时间戳格式成时间格式的。

unix_timestramp() 这个是将时间转化为时间戳的。
------解决方案--------------------
from_unixtime(); 1391952085 转 2014-02-09 21:21:25
unix_timestamp();2014-02-09 21:21:25 转 1391952085

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn