本文简单介绍mysql 的时间函数以及实例,感兴趣的朋友可以参考一下
mysql 的时间函数:
from_unixtime
from_unixtime(unix_timestamp, format)
第一个参数是时间戳格式。 第二个是最终想转换的格式,如
select from_unixtime(1436102304,'%y年%m月%d日') as date;
结果 date : 2015年07月05日
unix_timestamp
unix_timestamp(date)
则是将时间转化为时间戳,如
select unix_timestamp('2015-07-05');
结果是:1436068800
示例:找出2015-05到2015-07 log表中的记录:
select id, from_unixtime(time,'%y-%m-%d') as date
from log
where time between unix_timestamp('2015-05-01') and unix_timestamp('2015-07-01');
【相关推荐】
1. 免费mysql在线视频教程
2. mysql最新手册教程
3.布尔教育燕十八mysql入门视频教程
以上就是简单介绍mysql 的时间函数以及实例的详细内容。