Jump to content

Compare current date with the date in database


lukelee

Recommended Posts

Hi, Currently I am making a module for joomla. every article has an publish date, if the article was published in 7 days ago, it will displayed as "article in last week", My idea is to use today's date - publish date, if the result is greater than 7 and smaller than 14, the article will be displayed as "article in last week.

Any one know how to write this code?

Here is what I have got, but not working.

<?php
$todays_date = date("Y-m-d"); 

$result = mysql_query("select * from jos_content where $test between $todays_date-14 and $todays_date-7");  
while($row = mysql_fetch_array($result))
  {
echo "$todays_date - $row[title]";
}
?>

Link to comment
Share on other sites

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.