Retrieving date from MySQL into PHP

HI!

I am selecting and echoing a datetime array called $creation_time stored in my MySQL database via PHP. The PHP script echoes it fine but I would prefer it just to echo the month and year. Currently it displays 2010-05-28 00:00:00 while I would like it to echo just May 2010.

Any simple ways I can do this?

$keyid = $get['keyid'];

		$db = new Database(DB_CONF, $log);
		$db->execute('
			SELECT article.title, article.author_name, article.summary, article.creation_time
			FROM article
			WHERE article.category_name = "' . $keyid . '"
			ORDER BY creation_time ASC;');
			
		$res = $db->getAll();


		foreach ($res as $row) {
			$title = $row['title'];
			$author_name = $row['author_name'];
			$summary = $row['summary'];
			$creation_time = $row['creation_time'];
			
			$listofarticles .= "<p><b>$title</b> ($creation_time) <br />by $author_name <p> <i>$summary</i></p></p>";
		}

echo "$listofarticles";

MANY THANKS!

leao

Or you could use MySQL’s DATE_FORMAT() function.

Cheers,

Jon

$creation_time = date(‘M Y’,strtotime($creation_time));

date(‘M Y’,strtotime($creation_time));

brilliant!