dedecms列表中最近N天时间加红色

dedecms列表中最近N天时间加红色,只需要判断当前时间即可,代码如下:

[field:pubdate runphp='yes']   
$a="<font color=red>".strftime('%m-%d',@me)."</font>";  
$b=strftime('%m-%d',@me);  
$ntime = time();   
$day3 = 3600 * 24 * 3;  
if(($ntime - @me) < $day3) @me = $a;  
else @me =$b;   
[/field:pubdate] 

举例说明:

<ul>
    {dede:arclist titlelen='80' flag='a' row='30'}
    <li>
        <h2><a href="https://www.360muye.cn/ [field:arcurl/]" title="[field:title/]">[field:title/]</a></h2>
        <p>[field:description function="cn_substr(@me,220)"/]...</p>
        <span>[field:pubdate runphp='yes']   
$a="<font color=red>".strftime('%m-%d',@me)."</font>";  
$b=strftime('%m-%d',@me);  
$ntime = time();   
$day3 = 3600 * 24 * 3;  
if(($ntime - @me) < $day3) @me = $a;  
else @me =$b;   
[/field:pubdate]</span>
    </li>
    {/dede:arclist}    
</ul>

 

通过上面的代码即可实现最近3天内的文章时间显示红色,如果想调整时间为N,只需要吧3改成需要的天数即可。转载请注明:木业网

posted @ 2021-06-17 17:25  hepeacer  阅读(51)  评论(0)    收藏  举报