Jump to content

"New post" to appear on entries less than 2 weeks old


Amarok

Recommended Posts

I would like a special message to appear on post titles less than 2 weeks old. I thought the following code would do it but nothing is showing up, not even error messages, any suggestions? The date_post variable is a TIMESTAMP field in my MySQL table.

$date = date_parse($row["date_post"]);
$date = mktime($date["hour"], $date["minute"], $date["second"], $date["month"], $date["day"], $date["year"]);
if ((time() - (24*60*60*14)) < $date)
echo "<font color=red>new</font></li>";
else
echo "</li>";

Thanks for the suggestion pocobueno, still not working though...it actually does include the new, but it does so for every post including those older than 2 weeks. Can I ask where the $date variable is defined in your code? "$date - 14"? And in $row["date_post"] < $two_weeks_ago, does the "date_post" string need to be split into an array of some sort? I'm sorry, I am still trying to catch on to PHP, I appreciate the help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.