开发者

Show Recent Results Only

when i echo out the entries made in my database, i want to mark the ones less than three days old as 'New' or 'Latest' etc.

The script below marks them 开发者_C百科if they were posted today but i'm not sure how to test it against the above. Can someone amend this to reflect what i'm after?

<?php 
$today = date('d M Y');
if ($date = date('d M Y', strtotime($rsjobinfo['date'])) == $today) { ?>            
<p>NEW</p>
<?php 
;}
?> 

Thanks in advance Dan


time() will give you the current time, in seconds. You can subtract the date of the article (in seconds) to determine if it occurred in the last three days.

if ( ( time() - strtotime( $rsjobinfo['date']) ) < 259200 ) { // 259200 is the number of seconds in three days
    ?><p>NEW</p><?php
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜