Jump to content

Archived

This topic is now archived and is closed to further replies.

PattyB

Help using date_format()

Recommended Posts

Hi,

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.

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

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

Share this post


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

then
[code]
echo $row['date'];
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.