网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   DedeCMS (https://www.0058.net/forumdisplay.php?f=71)
-   -   当日更新文档日期红色显示 (https://www.0058.net/showthread.php?t=4727)

Uintah 2014-05-01 10:55 PM

当日更新文档日期红色显示
 
温馨提醒:本教程适用于DedeCMS 通用,V5.3,V5.5,V5.6
Code:



    [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() 做减法后判断情况输出结果。

比如:
Code:



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



All times are GMT +8. The time now is 04:06 AM.

Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.