Date conversion
Posted: Mon Feb 24, 2003 7:58 pm
Converting date format from MySQL (yyyy-mm-dd) field (type=date) into a word format using PHP.
Example: 2003-02-24 into February 24th 2003
The problem is when I echo $date It displays as December 31st 1969 instead of February 24th 2003
Example: 2003-02-24 into February 24th 2003
The problem is when I echo $date It displays as December 31st 1969 instead of February 24th 2003
Code: Select all
<?php
include "config.php";
$db = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");
$query = "SELECT title, news, author, date FROM news ORDER BY id DESC LIMIT 10";
$result = mysql_query($query);
while ($r = mysql_fetch_array($result)) {
$title = $r["title"];
$news = $r["news"];
$author = $r["author"];
$date = date("F jS Y", $r["date"]);
}
mysql_close($db);
?>