新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
php怎么查詢本年的數(shù)據(jù)
本文操作環(huán)境:Windows7系統(tǒng)、thinkphp v5.1版、Dell G3電腦。

東安ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來(lái)市場(chǎng)廣闊!成為創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:028-86922220(備注:SSL證書合作)期待與您的合作!
php怎么查詢本年的數(shù)據(jù)?
thinkphp查詢當(dāng)天,本周的,本月的,本年的數(shù)據(jù)
代碼如:
//當(dāng)天時(shí)間
$where['time'] = array(
array('egt',strtotime(date('Y-m-d',time())),
array('lt',strtotime(date('Y-m-d',time())).'+1 day')
);
// 本周時(shí)間
$where['time'] = array(
array('egt',strtotime(date('Y-m-d',time())).'-'.date('w',time()).' day'),
array('lt',strtotime(date('Y-m-d',time())).'+1 week -'.date('w',time()).' day');
);
// 本月時(shí)間
$where['time'] = array(
array('egt',strtotime(date('Y-m',time()))),
array('lt',strtotime(date('Y-m',time()).'+1 month'))
);
// 本年時(shí)間
$where['time'] = array(
array('egt',strtotime(date('Y',time()))),
array('lt',strtotime(date('Y',time()).'+1 year'))
);
上面是查詢條件,直接運(yùn)用到查詢語(yǔ)句就可以了
$result = $db->where($where)->select();
更正下上面的那個(gè) 本年 查詢時(shí)間
$where['time'] = array(
array('egt',strtotime(date('Y-01-01',time())),
array('lt',strtotime(date('Y-01-01',time()).'+1 year'))
);
修復(fù)版
//昨天時(shí)間
$yesterday['addtime'] = array(
array('egt',strtotime(date('Y-m-d',time()).' -1 day')),
array('lt',strtotime(date('Y-m-d',time())))
);
//當(dāng)天時(shí)間
$day['addtime'] = array(
array('egt',strtotime(date('Y-m-d',time()))),
array('lt',strtotime(date('Y-m-d',time()).' +1 day'))
);
// 本月時(shí)間
$month['addtime'] = array(
array('egt',strtotime(date('Y-m',time()))),
array('lt',strtotime(date('Y-m',time()).' +1 month'))
);
// 本周時(shí)間
$week['addtime'] = array(
array('egt',strtotime(date('Y-m-d',time()).'-'.date('w',time()).' day')),
array('lt',strtotime(date('Y-m-d',time()).'+1 week -'.date('w',time()).' day'))
); 網(wǎng)頁(yè)標(biāo)題:php怎么查詢本年的數(shù)據(jù)
本文來(lái)源:http://fisionsoft.com.cn/article/djehpho.html


咨詢
建站咨詢
