Date: 11/08/00
- Next message: John Guynn: "RE: [PHP-DB] Date weirdness (php/mysql) (code included)"
- Previous message: John Guynn: "[PHP-DB] Date weirdness (php/mysql) (code included)"
- In reply to: John Guynn: "[PHP-DB] Date weirdness (php/mysql) (code included)"
- Next in thread: John Guynn: "RE: [PHP-DB] Date weirdness (php/mysql) (code included)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 <email protected>
> For additional commands, e-mail: php-db-help <email protected>
> To contact the list administrators, e-mail: php-list-admin <email protected>
>
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: John Guynn: "RE: [PHP-DB] Date weirdness (php/mysql) (code included)"
- Previous message: John Guynn: "[PHP-DB] Date weirdness (php/mysql) (code included)"
- In reply to: John Guynn: "[PHP-DB] Date weirdness (php/mysql) (code included)"
- Next in thread: John Guynn: "RE: [PHP-DB] Date weirdness (php/mysql) (code included)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

