ahs10 Posted August 17, 2007 Share Posted August 17, 2007 i have a simple message board that shows the date an entry was posted. i have the list of entries sorted by date, however there is a problem. the sorting is not taking the year into consideration. for example, if a post with a date of 12/20/06 is considered newer than a post with a date of 4/20/07. i was hoping someone could give me some direction on where to look and how to fix this. if i need to post some code, i will, just let me know. Quote Link to comment https://forums.phpfreaks.com/topic/65437-problems-with-my-dates/ Share on other sites More sharing options...
lemmin Posted August 17, 2007 Share Posted August 17, 2007 Are you using a database to store these dates? A little more information would be helpful, probably some code, too. Quote Link to comment https://forums.phpfreaks.com/topic/65437-problems-with-my-dates/#findComment-326771 Share on other sites More sharing options...
ahs10 Posted August 17, 2007 Author Share Posted August 17, 2007 i am using a database. here's the code of a script that fetches the data and makes a table row out of it.... $strTemp2=$line['Issue']; $strTemp1=$line['ID']; $strTemp3=$line['Date']; $hotDate = date("m/d/y", strtotime($strTemp3)); $oldHot = date("m/d/y", strtotime("7 days ago")); if($hotDate <= $oldHot) { $hotStyle = "class=\"oldHot\""; } else { $hotStyle = "class=\"newHot\""; } $strTemp.= "<TR ".$pstrDataRowParameters.">"; $strTemp.="<TD ".$pstrDataColumnParameters."><span><A HREF =\"javascript:popper('IssueDetails.php?ID=" .$strTemp1. "','POPPER','width=900,height=700')\" ".$hotStyle.">• ".$strTemp2. "</A></span></TD>"; $strTemp.="<TD ".$pstrDataColumnParameters.">" .$strTemp3. "</TD>"; as you can see, i've added different css styles to posts that are newer (by seven days). this css style simply displays the post in red if it's new. this is working fine, but it too is marking posts without considering the year. for example today is 8/17/07 so it marks a posts dated 8/24/06 and 12/12/06 in red.... i'm thinking again because it isn't paying attention to the year which would mean that date hasn't happend yet. here's some code that displays the data (this is in the code of my site's index page)..... $strsql = "SELECT id as 'ID', title as 'Issue', DATE_FORMAT(date,'%m/%d/%y') as 'Date' "; $strsql .=" FROM hotTopics_US_topics "; $strsql .=" WHERE active='Y' "; $strsql .=" ORDER BY date DESC"; $strsql .=" LIMIT $start,$numentries"; Quote Link to comment https://forums.phpfreaks.com/topic/65437-problems-with-my-dates/#findComment-326790 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.