大家發現很多網站最新文章或者今天的文章發布時間標紅或者高亮顯示,就想把自己的也搞成這樣,心急卻不知道怎么寫代碼,下面我分享一下自己珍藏的方法分享給大家.
第一種方法,在需要的地方添加即可:
- [field:pubdate runphp='yes']
- $a="";
- $b="";
- $c=strftime("%Y年%m月%d日","@me");
- $ntime = time();
- $oneday = 3600 * 24;
- if(($ntime - @me)<$oneday) @me = $a.$c.$b;
- else @me =$c;
- [/field:pubdate]
PS:$a="";高亮顯示的顏色 $oneday = 3600 * 24; 一小時3600秒一天24小時 就是3600X24這么多秒,如果想48小時格式就是 $oneday = 3600 * 48; 根據需要進行編寫
第二種方法:
- [field:pubdate runphp='yes']
- $a="".strftime('%m-%d',@me)."";
- $b=strftime('%m-%d',@me);
- $ntime = time();
- $day3 = 3600 * 24;
- if(($ntime - @me) < $day3) @me = $a;
- else @me =$b; //開源軟件:Vevb.com
- [/field:pubdate]
PS:$a=""這個是顏色代碼,red 是紅色 自己可以改成需要的顏色即可,只要你懂英文就可以了,具體效果可以參考 http://www.survivalescaperooms.com
第三種方法跟第一種差不多,時間顯示格式不一樣.
- [field:pubdate runphp='yes']
- $a="";
- $b="";
- $c=strftime("%Y-%m-%d","@me");
- $ntime = time();
- $oneday = 3600 * 24;
- if(($ntime - @me)<$oneday) @me = $a.$c.$b;
- else @me =$c;
- [/field:pubdate]
- [field:pubdate function="MyDate('m-d',@me)"/]
新聞熱點
疑難解答