Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 03:41 pm EDT

Geeklog Forums

MySQL help: Long date to short date


nuccio

Anonymous
determined
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!
 Quote

ted

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

nuccio

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.
 Quote

All times are EDT. The time is now 03:41 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content