Jump to content

date function, how to use


jarv

Recommended Posts

I have a list of headers I use each week, I want to display some text on the lastest header stating it must be changed within 6 days!

 

ok say the $HeaderDate is 11th July as today is 16th July and $HeaderDate is within 6 days after then display "you have 1 day left to add a new header"

 

if the $HeaderDate is after 6 days  then display

"You must now add a new Header"

 

can some one please help?

Link to comment
Share on other sites

from the most recent header added, 6 days within that

so like:

 

$HeaderDate = 11th July

 

6 days left = 12th

5 days left = 13th

4 days left = 14th

3 days left = 15th

2 days left = (Today) 16th July

1 day left  = 17th

 

18th July = you must now change your header!

 

and then when I add a new header:

 

6 days left = 19th July

and so on!

 

 

 

echo <<<EOF
  <a title="$HeaderID" id="$HeaderID" name="$HeaderID"></a>
  <div class="entry_header">
    <b>Header Name:</b> $HeaderName <a href="edit.php?HeaderID=$HeaderID"><img src="images/picture_edit.png" border="0" /></a> <a href="upload.php?HeaderID=$HeaderID"><img src="images/picture_right.png" border="0" /></a><br />
      <b>Country:</b> <a href="http://www.avert.org/photo_search.php?search_keyword_id=&search_country_id=country-$CountryID&page_type=thumbnails&search=search" target="_blank">$Country</a> <b>Keywords:</b> 
EOF;
//loop through Keywords 
      $i = 0;
while ($row1 = mysql_fetch_array($result2))
{
    if ($i++ > 0)
    {
        echo ', ';
    }
   $Keyword = $row1['keyword'];
  $KeywordID = $row1['keyword_id'];
       echo '<a href="http://www.avert.org/photo_search.php?search_keyword_id='.$KeywordID.'&search_country_id=&page_type=thumbnails&search=search" target="_blank" >'.$Keyword.'</a>';
   echo ' <a href="editkeywords.php?HeaderID='.$HeaderID.'">[Edit]</a>';
}  
  
      
echo '<br />';
echo '<b>PhotoID:</b> '. $PhotoID .'<br />';
echo '<b>Header Photo No:</b> '. $HeaderPhotoNo .'<br />';
if $HeaderDate <= e
echo '<b>Header Date:</b> '.$HeaderDate.'<br />';
echo '<img src="headers/'.$HeaderImage.'">';
echo '</div>';
echo '</div>';

}

Link to comment
Share on other sites

For substraction try datediff:

SELECT DATEDIFF('2008-07-11','2008-07-16') as date;

For today date you can use curdate().Than instead of 2008-07-16 you can use curdate().

 

For overdate mean greater than today:

use greater >.

date > date1 { do this }

 

For adding days:

SELECT ADDDATE('2008-07-11', 06);

Will add 6 days.

 

If you want it in php:

<?php

$date = date('Y-m-d', strtotime("-30 days"));
$date = date('Y-m-d', strtotime("-10 years"));
$date = date('Y-m-d', strtotime("+30 days"));

?>

 

Link to comment
Share on other sites

how can i use this in my code?

 

at the moment i have:

 

if ($HeaderDate == date("d")+6) {
echo "<div class=\"poo\">";
  }
  else
  {
echo "<div class=\"entry_header\">";
  }

 

which doesn't work?!

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.