织梦DEDECMS模板调用某个时间段发布的文章的代码

//时间限制(用于调用最近热门文章、热门评论之类),这里的时间只能计算到天,否则缓存功能将无效
//当subday=1的时候调用1天内的文章
//当subday=2的时候调用昨天的文章
//当subday=3的时候调用2天前得所有文章

//当subday=7的时候调用7天内得所有文章

 

if($subday > 0) 
 { 
     if($subday == 1) 
 { 
  $ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y')); 
  $limitday = $ntime - ($subday * 24 * 3600); 
  $orwheres[] = " arc.senddate > $limitday "; 
 } 
   else if ($subday == 2) 
 {   
  $ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y')); 
  $limitday = $ntime - ($subday * 24 * 3600); 
  $lomitday = $ntime; 
  $orwheres[] = "  arc.senddate > $lomitday  &&  arc.senddate < $limitday"; 
 } 
  else if ($subday == 3) 
 {   
  $ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y')); 
  $limitday = $ntime -($subday * 24 * 3600)+(1*24 * 3600); 
  $orwheres[] = " arc.senddate < $limitday "; 
 } 
  else if ($subday == 7) 
 {   
  $ntime = gmmktime(0, 0, 0, gmdate('m'), gmdate('d'), gmdate('Y')); 
  $limitday = $ntime - ($subday * 24 * 3600); 
  $orwheres[] = " arc.senddate > $limitday "; 
 } 
 } 
 }