View Full Version : Date_Format

07-15-2006, 03:56 PM
I am trying to reformat my mySQL dates into some thing like this: Sun, Jul 9th 2006 04:56:23 PM, using Date_Format(date, '%a, %b %D %Y %r'), but it's not working. I don't know why, any help would be appreciated.

07-15-2006, 05:10 PM
Replace "date" with "Now()".

07-15-2006, 05:18 PM
Its not for the current time date is the col in my database.

Edit: This is the entire query:
$query = "SELECT `title`, `author`, Date_Format(date, '%a, %b %D %Y %r'), `content` FROM `news home` where `home` like 'home' order by `date` asc";

07-15-2006, 05:34 PM
Do you have a field called Date_Format or just date in your database? MySQL is probably going to have a problem with that. You need to rename those fields to something else.

07-15-2006, 05:40 PM
It's just date, but I will try that now.

07-15-2006, 06:08 PM
Well I figured it out, I guess it was putting it in a different variable so I added "as post" so I could use $row['post'] in my for loop. What is it by default? It wasn't "date" and that was my assumption.

07-16-2006, 12:35 AM
Ah, yes, that'll bite you for sure.

The default variable is literally the name of what you select, i.e.

$row["Date_Format(Now(), '%a, %b %D %Y %r')"]

Which, needless to say, would be unwieldy to work with :)

07-16-2006, 03:37 PM
If you are posting a question where you are using some application to display the output, please make sure to mention that in your question as well.

that would give folks a clue as to what could be the problem and point you towards that.

If it is strictly a mysql query you would have had no problems returning the result in your original post. It was the call to that column that gave you the problem.