Jump to content

problems with my dates


ahs10

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/65437-problems-with-my-dates/
Share on other sites

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";

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.