Jump to content

Displaying a Date


JSHINER

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.