Jump to content


Help using date_format()

  • Please log in to reply
1 reply to this topic

#1 PattyB

  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 18 September 2006 - 11:48 PM


I have the following code using date_format but it does not return anything.  Am I using this right
or is there a problem somewhere else?  If I have just date it returns the value fine.

$newsquery = "SELECT id, author, title, article, date 
FROM news order by date DESC LIMIT 0, 3";
$newsresult = mysql_query($newsquery);

<tr width=100%>
<td width="40%" align="left">
<?php echo $row["date_format(date, '%m-%d-%Y')"];  ?>

#2 Barand

  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 18 September 2006 - 11:56 PM

date_format is a SQL function an so needs to go in the query.
$newsquery = "SELECT id, author, title, article, date_format(date, '%m-%d-%Y') as date
FROM news order by date DESC LIMIT 0, 3";

echo $row['date'];

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received


|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users