真正的“当天”显示红色,实现代码:
1 |
[field:pubdate runphp= 'yes' ] |
2 |
if ( date ( "Y-m-d" ,@me)== date ( "Y-m-d" )){ |
3 |
@me= '<font color="#FF0000">' .GetDateTimeMK(@me). '</font>' ; |
6 |
@me=GetDateTimeMK(@me); |
|
在上面的代码中,我们使用了dedecms的标准时间函数(GetDateTimeMK(@me)),显示出来的时间是格式:2010-10-17 21:40:36,如果您想要其它格式,例如:年月日,那么实现代码如下:
1 |
[field:pubdate runphp= 'yes' ] |
2 |
if ( date ( "Y-m-d" ,@me)== date ( "Y-m-d" )){ |
3 |
@me= '<font color="#FF0000">' .MyDate( 'Y-m-d' ,@me). '</font>' ; |
5 |
@me=MyDate( 'Y-m-d' ,@me); |
|
再来看下24小时内发表的文章,显示红色的代码,我们直接用 pubdate - time() 做减法后判断情况输出结果。
代码如下:
1 |
[field:pubdate runphp= 'yes' ] |
3 |
if ( $nowTime - (3600 * 24) < @me){ |
4 |
@me= '<font color="#FF0000">' .GetDateTimeMK(@me). '</font>' ; |
6 |
@me=GetDateTimeMK(@me); |
|
时间格式与当天的修改方法是一样的。不再赘述。