barney0o0 Posted March 9, 2006 Share Posted March 9, 2006 Sorry, i know its been discussed on numerous occasions in the forums, but my head hurts for the simpliest of things.....How do i change the code below to change the format from 2002-12-27 (database format) to 27 December 2002(pulled down display format)?SELECT eventTITLE, eventDATEFROM eventsORDER BY eventDATE ASC...or would it be more efficant to change the format in php prior to pulling down the results?Thanks in advance Quote Link to comment Share on other sites More sharing options...
lessthanthree Posted March 9, 2006 Share Posted March 9, 2006 [!--quoteo(post=353184:date=Mar 9 2006, 08:47 AM:name=barney0o0)--][div class=\'quotetop\']QUOTE(barney0o0 @ Mar 9 2006, 08:47 AM) [snapback]353184[/snapback][/div][div class=\'quotemain\'][!--quotec--]Sorry, i know its been discussed on numerous occasions in the forums, but my head hurts for the simpliest of things.....How do i change the code below to change the format from 2002-12-27 (database format) to 27 December 2002(pulled down display format)?SELECT eventTITLE, eventDATEFROM eventsORDER BY eventDATE ASC...or would it be more efficant to change the format in php prior to pulling down the results?Thanks in advance[/quote]I prefer to manipulate my date formats with PHP. [code]$query = mysql_query("SELECT eventTITLE, eventDATE FROM events ORDER BY eventDATE ASC");if ($row = mysql_fetch_assoc($query)){ do { $date = date("d/m/Y", strtotime($row["eventDATE"])); } while ($row = mysql_fetch_assoc($query));}[/code] Quote Link to comment Share on other sites More sharing options...
barney0o0 Posted March 9, 2006 Author Share Posted March 9, 2006 Cheers lessthan for your response....I had i play with your sugesstion, but as im using dreamweavers behaviours to display the pulled down data i got in a bit of a mess....Ive now played and searched around and come up with:SELECT DATE_FORMAT(eventdate2, '%D/%M/%Y') AS eventdate2, eventTITLE,paratextFROM eventsORDER BY eventdate2that produces7th/February/2006Music night2Intro textIs there a way to remove the forward slashes and replace with a space?many thanks Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 9, 2006 Share Posted March 9, 2006 [!--quoteo(post=353290:date=Mar 9 2006, 11:06 AM:name=barney0o0)--][div class=\'quotetop\']QUOTE(barney0o0 @ Mar 9 2006, 11:06 AM) [snapback]353290[/snapback][/div][div class=\'quotemain\'][!--quotec--]Is there a way to remove the forward slashes and replace with a space?many thanks[/quote]sure, just adjust your DATE_FORMAT function:[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] DATE_FORMAT(eventdate2, [color=red]'%D %M %Y'[/color]) [color=green]AS[/color] eventdate2, eventTITLE,paratext[color=green]FROM[/color] [color=orange]events[/color] [color=green]ORDER BY[/color] eventdate2[!--sql2--][/div][!--sql3--] Quote Link to comment Share on other sites More sharing options...
barney0o0 Posted March 9, 2006 Author Share Posted March 9, 2006 As per usual, things seem so so easy when theyre spelt out...many thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.