Jump to content

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


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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.