Re: Date weirdness (php/mysql) (code included)

From: Date: Wed, 08 Nov 2000 21:29:59 +0000
Subject: Re: Date weirdness (php/mysql) (code included)
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-4315@lists.php.net to get a copy of this message
Please read: http://www.php.net/manual/function.date.php The second argument to date() is in standard Unix timestamp format. ie. the number of seconds since jan.1 1970. You can use mktime() to generate this timestamp for you. -Rasmus On Wed, 8 Nov 2000, John Guynn wrote: > 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 > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#4315) next »