JSHINER Posted March 22, 2007 Share Posted March 22, 2007 My current code: foreach ($page['events'] as $z) { echo '<b>', $z['date'], '</b></p>'; } Which is pulling "date" from a DATE field in the database. Would like it to display as 3-22-2007 ... instead of 2007-3-22 - I know theres a quick answer out there but cant find it. Thanks in advance for any help. Link to comment https://forums.phpfreaks.com/topic/43889-displaying-a-date/ Share on other sites More sharing options...
DeathStar Posted March 22, 2007 Share Posted March 22, 2007 try inserting it in that format! Link to comment https://forums.phpfreaks.com/topic/43889-displaying-a-date/#findComment-213043 Share on other sites More sharing options...
paul2463 Posted March 22, 2007 Share Posted March 22, 2007 $query = "SELECT DATE_FORMAT(date_column,'%d-%m-%Y') AS formatdate from table"; echo '<b>', $z['formatdate'], '</b></p>'; Link to comment https://forums.phpfreaks.com/topic/43889-displaying-a-date/#findComment-213044 Share on other sites More sharing options...
JSHINER Posted March 22, 2007 Author Share Posted March 22, 2007 function getEvents($db, $id = false) { $query = "SELECT DATE_FORMAT(date,'%d-%m-%Y') AS formatdate FROM table"; $arr = $db->getArray("SELECT title, date, link, description FROM table WHERE id = '$id' ORDER BY date ASC"); return $arr; I have the above - $z['formatdate'] is not displaying the date. It's coming up as blank. What am I doing wrong ? Link to comment https://forums.phpfreaks.com/topic/43889-displaying-a-date/#findComment-213087 Share on other sites More sharing options...
paul2463 Posted March 23, 2007 Share Posted March 23, 2007 function getEvents($db, $id = false) { $arr = $db->getArray("SELECT title, DATE_FORMAT(date,'%d-%m-%Y') AS formatdate, link, description FROM table WHERE id = '$id' ORDER BY date ASC"); // is the table you are pulling the information from called table ??? if not alter the above to read the name of your table return $arr; } Link to comment https://forums.phpfreaks.com/topic/43889-displaying-a-date/#findComment-213796 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.