復(fù)制代碼
十年專業(yè)網(wǎng)站制作公司歷程,堅(jiān)持以創(chuàng)新為先導(dǎo)的網(wǎng)站服務(wù),服務(wù)超過(guò)成百上千家企業(yè)及個(gè)人,涉及網(wǎng)站設(shè)計(jì)、重慶APP開(kāi)發(fā)公司、微信開(kāi)發(fā)、平面設(shè)計(jì)、互聯(lián)網(wǎng)整合營(yíng)銷等多個(gè)領(lǐng)域。在不同行業(yè)和領(lǐng)域給人們的工作和生活帶來(lái)美好變化。
代碼如下:
echo
date("Ymd",strtotime("now")),
"\n";
echo
date("Ymd",strtotime("-1
week
Monday")),
"\n";
echo
date("Ymd",strtotime("-1
week
Sunday")),
"\n";
echo
date("Ymd",strtotime("+0
week
Monday")),
"\n";
echo
date("Ymd",strtotime("+0
week
Sunday")),
"\n";
//date('n')
第幾個(gè)月前基
//date("w")
本周周幾
//date("t")
本月天數(shù)
echo
'br上周:br';
echo
date("Y-m-d
H:i:s",mktime(0,
,
0,date("m"),date("d")-date("w")+1-7,date("Y"))),"\n";
echo
date("Y-m-d
H:i:s",mktime(23,59,59,date("m"),date("d")-date("w")+7-7,date("Y"))),"\n";
echo
'br本周:br';
echo
date("Y-m-d
H:i:s",mktime(0,
,
0,date("m"),date("d")-date("w")+1,date("Y"))),"\n";
echo
date("Y-m-d
H:i:s"沒(méi)稿,mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"))),"\n";
echo
'br上月:br';
echo
date("Y-m-d
H:i:s",mktime(0,
,
0,date("m")-1,1,date("Y"))),"\n";
echo
date("Y-m-d
H:i:s",mktime(23,59,59,date("m")
,0,date("Y"))),"\n";
echo
'br本月:br';
echo
date("Y-m-d
H:i:s",mktime(0,
,
0,date("m"),1,date("Y"))),"\n";
echo
date("Y-m-d
H:i:s",mktime(23,59,59,date("m"),date("t"),date("Y"))),"\n";
$getMonthDays
=
date("t",mktime(0,
,
0,date('n')+(date('n')-1)%3,1,date("Y")));//本季度未最后一月天數(shù)
echo
'枯悔孝br本季度:br';
echo
date('Y-m-d
H:i:s',
mktime(0,
0,
0,date('n')-(date('n')-1)%3,1,date('Y'))),"\n";
echo
date('Y-m-d
H:i:s',
mktime(23,59,59,date('n')+(date('n')-1)%3,$getMonthDays,date('Y'))),"\n";
/*今天*/
select?*?from?表名?where?to_days(時(shí)間字段)?=?to_days(now());
/*昨天*/
select?*?from?表名?where?to_days(now())-to_days(時(shí)間字段)?=?1;
/*近7天*/
select?*?from?表名?where?date_sub(curdate(),?interval?7?day)?=?date(時(shí)間字段);
/*查詢距離當(dāng)前現(xiàn)在6個(gè)月的數(shù)據(jù)*/
select?*?from?表名?where?時(shí)答游如間字段?between?date_sub(now(),interval?6?month)?and?now();
/*查詢當(dāng)前這周的數(shù)據(jù)*/
select?*?from?表名?where?yearweek(date_format(時(shí)間字段,'%Y-%m-%d'))?=?yearweek(now());
/*查磨祥詢上周的數(shù)據(jù)*/
select?*?from?表名?where?yearweek(date_format(時(shí)間字段,'%Y-%m-%d'))?=?yearweek(now())-1;
/*查詢當(dāng)前月份的數(shù)據(jù)*/
select?*?from?表名?where?date_format(時(shí)清啟間字段,'%Y-%m')=date_format(now(),'%Y-%m');
/*查詢上個(gè)月的數(shù)據(jù)*/
select?*?from?表名?where?date_format(時(shí)間字段,'%Y-%m')=date_format(date_sub(curdate(),?interval?1?month),'%Y-%m');
其它獲取類似以上的代碼顯示
echo date('Y-m-d',strtotime ( "last Monday -1 week"仔做敏 )), "\n" ;
echo date('Y-m-d'胡段,strtotime ( "last Sunday" )), "\n" ;
通過(guò)這個(gè)函數(shù)獲取上個(gè)周念枝的開(kāi)始和結(jié)束,然后sql查詢
可以研究下這個(gè)函數(shù)strtotime ??梢詽M足你的需求
文章題目:php獲取上周數(shù)據(jù)內(nèi)容 php獲取上個(gè)月
網(wǎng)頁(yè)鏈接:http://jinyejixie.com/article36/ddpiisg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、服務(wù)器托管、商城網(wǎng)站、域名注冊(cè)、App設(shè)計(jì)、微信小程序
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)