Amarok Posted August 29, 2007 Share Posted August 29, 2007 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/67249-new-post-to-appear-on-entries-less-than-2-weeks-old/ Share on other sites More sharing options...
pocobueno1388 Posted August 29, 2007 Share Posted August 29, 2007 Give this a try: <?php $two_weeks_ago = date ('Y-m-d', strtotime ("$date - 14")); if (($row["date_post"] < $two_weeks_ago) echo "<font color=red>new</font></li>"; else echo "</li>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/67249-new-post-to-appear-on-entries-less-than-2-weeks-old/#findComment-337341 Share on other sites More sharing options...
Amarok Posted August 30, 2007 Author Share Posted August 30, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/67249-new-post-to-appear-on-entries-less-than-2-weeks-old/#findComment-337596 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.