Re: how to display new icon for news posted within 2 days?
| From: | Shawn McKenzie | Date: | Thu, 15 Jan 2009 20:02:01 +0000 |
| Subject: | Re: how to display new icon for news posted within 2 days? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-286459@lists.php.net to get a copy of this message | ||
paragasu wrote:
> is it possible to do it like
SELECT *, UNIX_TIMESTAMP(post_date)-172,800 as is_new FROM tbl
>
$post = mysqli_fetch_object($sql);
if($post->is_new)
echo '<img src=new.gif">';
From what I can tell, you'll just have a timestamp 2 days earlier than
the actual post date in the is_new var. So unless the post date is
0000172800 or earlier it will eval to true. How about:
SELECT *, UNIX_TIMESTAMP(post_date) as ts FROM tbl
if($post->ts > (time()-172800)) {
echo '<img src="new.gif">';
}
--
Thanks!
-Shawn
http://www.spidean.com