Forum Moderators: coopster

Message Too Old, No Replies

date() function within 'while' loop

         

PianoGuy

2:53 pm on Oct 13, 2005 (gmt 0)

10+ Year Member



Hey guys,

I don't want to come off as going to the well too often, but I can't seem to find any resources to help me on this at php.net

I am trying to utilize the date() function to modify the format of the value returned from my database within an array variable. I have used a 'while' statement to create an event list, but am unable to use the date() function within the loop. When I set the variable outside of the loop, that hasn't worked either.

This code works in every way except the date format, which I would like to be date('D M j',$Events[EVENT_DATE]):

NOTE: I could be a little hazy on my syntax. I don't have my code in front of me, and I still have to reference the manual for some syntax (the quotes in particular). But the code I have at home works fine, except for the date format.

$Result = mysql_query(SELECT * from 'EVENTS' ORDER BY 'EVENT_DATE')

while $Events = mysql_fetch_array($Result, MYSQL_ASSOC){
echo "<b>$Events[EVENT_DATE]</b><br>";
echo "<b>$Events[EVENT]</b><br>";
echo "<b>$Events[EVENT_DESC]</b><br><br>";
}

This, of course produces a list that looks like:

2005-10-12
Event
Event Description

and so on...

I've tried numerous combinations, and have had no success. This seems like it should be simple, but I just don't see it.

I really should probably just get some sleep one of these days...

PianoGuy
Sleepless

dcrombie

3:16 pm on Oct 13, 2005 (gmt 0)



This might help:

echo "<b>" . date('D M j', strtotime($Events[EVENT_DATE])) . "</b><br>";

;)

PianoGuy

5:33 pm on Oct 13, 2005 (gmt 0)

10+ Year Member



Thanks, DCrombie --

I didn't see that possibility. I'm getting there, though...

;)