display new icon based on db timestamp
this works in mysql5+. we want to display a small icon if the post_date is less than 2 days old. Unix timestamp is second. so for 2 days
60 * 60 * 24 * 2 = 172800
SQL query
SELECT IF((UNIX_TIMESTAMP() - UNIX_TIMESTAMP(post_date)) < 172800, 1, 0) AS is_new FROM tbl_news
then the php code will be
$p = mysqli_fecth_object($sql)
$p->is_new ? echo '<img src="new.gif">' : '';