vetman Posted October 4, 2009 Share Posted October 4, 2009 It show up as this: 2009-10-03, what I want is this: 10-03-2009. Any help would be appreciated! Thanks <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <title></title> <head> <link rel="stylesheet" href="./stylesheet/stylesheet1.css" media="screen"> <style type="text/css" media="screen">@import url("./stylesheet/stylesheet2.css");</style> </head> <body> <?php // Make a MySQL Connection include 'config.php'; //include 'style_1.php'; $con = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname) or die(mysql_error()); //echo "Connected to Database <br>"; // Retrieve all the data from the "news" table $result = mysql_query("SELECT * FROM news") or die(mysql_error()); // store the record of the "news" table into $row $current = ''; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { $id = $row['id']; if (!$current) { echo "<center><div><table border='0' width='600'>"; $current = $id; } elseif ($current != $id){ echo "</table></div><br><br><div><table border='0' width='600'>"; $current = $id; } // Print out the contents of each row into a table echo "<tr><td>{$row['postdate']}</td></tr>"; echo "<tr><td>{$row['title']}</td></tr>"; echo "<tr><td>{$row['content']}</td></tr>"; } echo "</table></div></center>"; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/176469-i-cant-figure-out-how-to-convert-a-date-from-the-database/ Share on other sites More sharing options...
.josh Posted October 4, 2009 Share Posted October 4, 2009 option 1: use date_format in your sql query option 2: use strtotime and date option 3: explode at the - and just concat the elements in the desired order. Link to comment https://forums.phpfreaks.com/topic/176469-i-cant-figure-out-how-to-convert-a-date-from-the-database/#findComment-930196 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.