Subject: MySQL help: Long date to short date

Posted on: 10/10/05 04:53pm
By: Anonymous

Hi all,

I have placed this piece of code on my front page, to show the 5 most recent stories posted on my homepage:

<?
$numStories = 5;
$result = mysql_query("SELECT sid, date, title FROM gl_stories ORDER BY `date` DESC LIMIT $numStories&quotWink or die(mysql_error());
if (mysql_num_rows($result)) {
while ($qry = mysql_fetch_array($result)) {
echo " <a href="http://www.martinhover.dk/article.php/$qry[sid]">$qry[date] - $qry[title]</a><br> n";
} ; }
?>

The code produces a link that looks something like this:
2005-09-17 20:29:18 - First week in Barcelona

Can anyone help me change the date format into the following: 2005/09/17?

Thank you very much!

MySQL help: Long date to short date

Posted on: 10/10/05 06:06pm
By: Anonymous

check this function in the php man--strftime()

MySQL help: Long date to short date

Posted on: 14/10/05 06:30pm
By: Anonymous

Thank you. I couldn't make that work, but found a way to use the function str_replace() to deliver the result I wanted:

str_replace('-','/',substr($qry['date'],0,10)), which produces the format 2005/09/17.

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=58618