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');
用户登录
还没有账号?立即注册
用户注册
投稿取消
| 文章分类: |
|
还能输入300字
上传中....
长发公主小杰子