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

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.