dede织梦24小时发表文章显示红色代码

DEDE织梦其实还是很强大的,可以实现众多的想法,比如今天571免费资源想要让当天发布的文章时间显示红色,那么有几种办法可以使用,而且此方法可以实现任意天数发布文章变红的效果。

真正的“当天”显示红色,实现代码:
[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]
在上面的代码中,我们使用了dedecms的标准时间函数(GetDateTimeMK(@me)),显示出来的时间是格式:2016-11-15 21:40:36,如果您想要其它格式,例如:年月日,那么实现代码如下:
[field:pubdate runphp='yes']
if(date("Y-m-d",@me)==date("Y-m-d")){
@me='<font color="#FF0000">'.MyDate('Y-m-d',@me).'</font>';
}else{
@me=MyDate('Y-m-d',@me);
}
[/field:pubdate]
再来看下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]
时间格式与当天的修改方法是一样的。不再赘述。

想要实现更多天数的时间变红,可以自行修改。

→ 点此获取正规游戏试玩赚钱软件~

游乐星球 点此下载

相关推荐

暂无评论

发表评论

您的电子邮件地址不会被公开,必填项已用*标注。