Welcome to Geeklog, Anonymous Sunday, November 24 2024 @ 01:37 am EST

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 EST. The time is now 01:37 am.

  • 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