PDA

View Full Version : 当日更新文档日期红色显示


Uintah
2014-05-01, 10:55 PM
温馨提醒:本教程适用于DedeCMS 通用,V5.3,V5.5,V5.6



[field:pubdate runphp='yes']   
if(date("Y-m-d",@me)==date("Y-m-d")){   
    @me='<font color="#FF0000">'.GetDateTimeMK(@me).'</font>';    
}else{   
    @me=GetDateTimeMK(@me);   
}    
[/field:pubdate]  



如果需要显示其他的格式,比如显示年月日,那么就修改一下 @me=GetDateTimeMK(@me) 和 @me='<font color="#FF0000">'.GetDateTimeMK(@me).'</font>'; 的显示函数,比如@me = MyDate('Y-m-d',@me);

其它的情况大家去摸索一下吧。

P.s:至于24小时内,那就更简单了,直接用 pubdate - time() 做减法后判断情况输出结果。

比如:



[field:pubdate runphp='yes']   
$nowTime = time();   
if($nowTime - (3600 * 24) < @me){   
    @me='<font color="#FF0000">'.GetDateTimeMK(@me).'</font>';    
}else{   
    @me=GetDateTimeMK(@me);   
}    
[/field:pubdate]