jarv Posted July 16, 2008 Share Posted July 16, 2008 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 https://forums.phpfreaks.com/topic/115013-date-function-how-to-use/ Share on other sites More sharing options...
DeanWhitehouse Posted July 16, 2008 Share Posted July 16, 2008 so first off, you want the code to count how many days until the header needs to be changed and then after this amount of days you want to display the text("You must now add a new Header")? Can u please paste the code with the header in aswell. Link to comment https://forums.phpfreaks.com/topic/115013-date-function-how-to-use/#findComment-591449 Share on other sites More sharing options...
jarv Posted July 16, 2008 Author Share Posted July 16, 2008 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 https://forums.phpfreaks.com/topic/115013-date-function-how-to-use/#findComment-591466 Share on other sites More sharing options...
jarv Posted July 17, 2008 Author Share Posted July 17, 2008 can anyone help me on this please? Link to comment https://forums.phpfreaks.com/topic/115013-date-function-how-to-use/#findComment-592256 Share on other sites More sharing options...
mmarif4u Posted July 17, 2008 Share Posted July 17, 2008 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 https://forums.phpfreaks.com/topic/115013-date-function-how-to-use/#findComment-592258 Share on other sites More sharing options...
jarv Posted July 17, 2008 Author Share Posted July 17, 2008 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 https://forums.phpfreaks.com/topic/115013-date-function-how-to-use/#findComment-592371 Share on other sites More sharing options...
jarv Posted July 18, 2008 Author Share Posted July 18, 2008 can anyone please help? Link to comment https://forums.phpfreaks.com/topic/115013-date-function-how-to-use/#findComment-593237 Share on other sites More sharing options...
DeanWhitehouse Posted July 18, 2008 Share Posted July 18, 2008 use something like this <?php $date = date('Y-m-d', strtotime("-6 days")); if($HeaderDate == $date) { echo "Time to change"; } ?> Link to comment https://forums.phpfreaks.com/topic/115013-date-function-how-to-use/#findComment-593275 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.