Re: how to display new icon for news posted within 2 days?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



That should work as well

Bastien

Sent from my iPod

On Jan 15, 2009, at 4:14 AM, paragasu <paragasu@xxxxxxxxx> 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">';

On 1/14/09, Phpster <phpster@xxxxxxxxx> wrote:
Make it easy and store the date as a unix timestamp. Then it's a
simple test    to do

If ((current timestamp - db timestamp) < 172,800 ){
 echo '<img src='new.gif'>';
}

Conversely, you can use strtotime() to convert the date.

Bastien

Sent from my iPod

On Jan 14, 2009, at 10:36 PM, paragasu <paragasu@xxxxxxxxx> wrote:

i do have a mysql table with one date field.
what i want is to display and tiny icon (red new icon) so user will
notice it is a new post.
i am looking for the simplest solutions here.

i believe we can calculate whether the date is within two days of user
current time.
then we display an icon based on it.

can anyone help?

thanks

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux