方法1、
顯示一周內(nèi)信息點(diǎn)擊排行
[e:loop={"select * from {$dbtbpre}ecms_news where FROM_UNIXTIME(newstime)>SUBDATE(NOW(),INTERVAL 7 DAY) order by onclick desc limit 10",0,24,0}]
=$bqr['title']?> [/e:loop]
或者
[e:loop={"select * from {$dbtbpre}ecms_news where newstime>UNIX_TIMESTAMP()-86400*7 order by onclick desc limit 10",0,24,0}]
=$bqr['title']?> [/e:loop]
或
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*7','onclick desc'}]
=$bqr[title]?>[/e:loop]
newstime:文章發(fā)布時(shí)間
其中86400*7中的7表示天,如果是月就是30 年就是365
其排列方式:文章發(fā)布時(shí)間起統(tǒng)計(jì)
今天(24小時(shí)):newstime>UNIX_TIMESTAMP()-86400*1 必須是今天發(fā)布的文章
一周:newstime>UNIX_TIMESTAMP()-86400*7 必須是一周內(nèi)發(fā)布的文章
舉例:
昨天:
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
?>
[e:loop={"select * from [!db.pre!]ecms_news where newstime BETWEEN $beginYesterday and $endYesterday order by onclick desc limit 10",0,24,0}]
標(biāo)題:
=$bqr[title]?>---點(diǎn)擊:=$bqr[onclick]?>
[/e:loop]
----------------------------------------
今天:
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*1','onclick desc'}]
標(biāo)題:
=$bqr[title]?>---點(diǎn)擊:=$bqr[onclick]?>
[/e:loop]
----------------------------------------
一周:
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*7','onclick desc'}]
標(biāo)題:
=$bqr[title]?>---點(diǎn)擊:=$bqr[onclick]?>
[/e:loop]
----------------------------------------
一月:
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*30','onclick desc'}]
標(biāo)題:
=$bqr[title]?>---點(diǎn)擊:=$bqr[onclick]?>
[/e:loop]
----------------------------------------
三月:
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*90','onclick desc'}]
標(biāo)題:
=$bqr[title]?>---點(diǎn)擊:=$bqr[onclick]?>
[/e:loop]
----------------------------------------
一年:
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*365','onclick desc'}]
標(biāo)題:
=$bqr[title]?>---點(diǎn)擊:=$bqr[onclick]?>
[/e:loop]
----------------------------------------
全部:
[e:loop={'news',10,18,0,'','onclick desc'}]
標(biāo)題:
=$bqr[title]?>---點(diǎn)擊:=$bqr[onclick]?>
[/e:loop]
方法2、
昨天:
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
?>
[e:loop={"select * from [!db.pre!]ecms_news where newstime BETWEEN $beginYesterday and $endYesterday order by onclick desc limit 10",0,24,0}]
標(biāo)題:
=$bqr[title]?>---點(diǎn)擊:=$bqr[onclick]?>
[/e:loop]
注釋?zhuān)?br />
//php獲取今日開(kāi)始時(shí)間戳和結(jié)束時(shí)間戳
$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
$endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
//php獲取昨日起始時(shí)間戳和結(jié)束時(shí)間戳 (即:前一天)
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
//調(diào)取這兩天(包括今天):(修改昨天)--date('d')-1:這兩天 、date('d')-2:這三天、以此類(lèi)推(注意:$beginYesterday、$endYesterday這兩個(gè)未改動(dòng),還是沿用的昨天的名稱(chēng))
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
//調(diào)取前兩天(修改昨天)--date('d')-2:前兩天 、date('d')-3:前三天、以此類(lèi)推(注意:$beginYesterday、$endYesterday這兩個(gè)未改動(dòng),還是沿用的昨天的名稱(chēng))
$beginYesterday=mktime(0,0,0,date('m'),date('d')-2,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
//php獲取上周起始時(shí)間戳和結(jié)束時(shí)間戳
$beginLastweek=mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'));
$endLastweek=mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'));
//php獲取本周起始時(shí)間戳和結(jié)束時(shí)間戳
$beginThisweek=mktime(0,0 ,0,date("m"),date("d")-date("w")+1,date("Y"));
$endThisweek=mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
//php獲取上月起始時(shí)間戳和結(jié)束時(shí)間戳
$beginLastmonth=mktime(0,0,0,date("m")-1,1,date("Y"))
$endLastmonth=mktime(23,59,59,date("m"),0,date("Y"))
//php獲取本月起始時(shí)間戳和結(jié)束時(shí)間戳
$beginThismonth=mktime(0,0,0,date('m'),1,date('Y'));
$endThismonth=mktime(23,59,59,date('m'),date('t'),date('Y'))