Date weirdness (php/mysql) (code included)

From: Date: Wed, 08 Nov 2000 20:26:51 +0000
Subject: Date weirdness (php/mysql) (code included)
Groups: php.db 
Request: Send a blank email to php-db+get-4314@lists.php.net to get a copy of this message
I am storing dates in a MySQL database in the YYYY-MM-DD format. $thisyear = "2000"; (sets current year) echo $thisyear."<br>"; (debugging code) $result = mysql_query("SELECT * FROM news WHERE YEAR(thedate) = '$thisyear' ORDER BY thedate"); (select statement) while ($row = mysql_fetch_array ($result)) { echo "<br>".$row[thedate]."<br>"; (debugging again) printf ("<h5 class=\"h5headl\">%s </h5>",date("F d, Y",$row[thedate])); (prints EVERY date as December 31, 1969) echo "<p class=\"story\">"; printf ("%s <a href=\"mar2000.php3\">%s's Results</a>",$row[info],date("F",$row[thedate])); (prints EVERY month as December) echo "<br>"; } What am I doing wrong? Is php's date() expecting a different format than YYYY-MM-DD? The date range from 2000-03-26 to 2000-07-30. Nothing near 1969-12-31. Ideas or suggestions appreciated. John Guynn

« previous php.db (#4314) next »