sprint10s Posted March 10, 2010 Share Posted March 10, 2010 im trying to change the date from default to Month Day, Year. Basically the user fills out a form then i echo the results in a table but the date format that i got in my code didn't change the default date. You can see what the output looks like at www.standridgemotorsports.com/jeremy_schedule1.php below is the code. thanks for any help. $result = mysql_query("SELECT *,DATE_FORMAT('h0237','%M-%d-%Y') FROM jos_jforms_72563 WHERE uid = 63 ORDER BY h0237 ASC"); echo "<table align='center' border='1'> <tr> <th>Date</th> <th>Track</th> <th>Description</th> <th>Special Show</th> <th>Race Type</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['h0237'] . "</td>";//Date echo "<td>" . $row['h9ca9'] . "</td>";//Track echo "<td>" . $row['hf6a6'] . "</td>";//Description echo "<td>" . $row['h67d6'] . "</td>";//Special Show echo "<td>" . $row['heb76'] . "</td>";//Race Type echo "</tr>"; } echo "</table>"; Quote Link to comment https://forums.phpfreaks.com/topic/194728-displaying-date-different-from-default/ Share on other sites More sharing options...
The Eagle Posted March 10, 2010 Share Posted March 10, 2010 If you want a 2 digit number of the date, you're going to have to make that capital M lowercased. If not it'll display 3 letters of that month. Do not think you need them "%" either. Quote Link to comment https://forums.phpfreaks.com/topic/194728-displaying-date-different-from-default/#findComment-1024040 Share on other sites More sharing options...
sprint10s Posted March 10, 2010 Author Share Posted March 10, 2010 the 3 letters for the month is fine if i can just get it to display. Quote Link to comment https://forums.phpfreaks.com/topic/194728-displaying-date-different-from-default/#findComment-1024042 Share on other sites More sharing options...
The Eagle Posted March 10, 2010 Share Posted March 10, 2010 Can I see "h0237" ? Quote Link to comment https://forums.phpfreaks.com/topic/194728-displaying-date-different-from-default/#findComment-1024046 Share on other sites More sharing options...
sprint10s Posted March 10, 2010 Author Share Posted March 10, 2010 Sorry no offense just don't know if i trust giving remote access it but here is a pic of the tables [/img] [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/194728-displaying-date-different-from-default/#findComment-1024048 Share on other sites More sharing options...
The Eagle Posted March 10, 2010 Share Posted March 10, 2010 You're able to change it in MySQL. Anyways, try removing %. Quote Link to comment https://forums.phpfreaks.com/topic/194728-displaying-date-different-from-default/#findComment-1024051 Share on other sites More sharing options...
sprint10s Posted March 10, 2010 Author Share Posted March 10, 2010 got rid of % and what should i change it to in Mysql Quote Link to comment https://forums.phpfreaks.com/topic/194728-displaying-date-different-from-default/#findComment-1024057 Share on other sites More sharing options...
PFMaBiSmAd Posted March 10, 2010 Share Posted March 10, 2010 A) Why are you using column names that don't convey the meaning of the column? That just makes writing code 10 times slower because you must keep looking-up and cross-referencing what they mean. B) The DATE_FORMAT() term would need to be referenced as $row['DATE_FORMAT()'] if I remember correctly. You should use an alias name in the query, which is what you were shown in the solution in a previous thread on this same problem, which is why you should not keep starting new threads for the same problem. You would then reference the alias name $row['dt'] to access the formatted value. C) There should be no single-quotes around the 'h0237' column name in the query as that would make it a string value instead of a column reference. Quote Link to comment https://forums.phpfreaks.com/topic/194728-displaying-date-different-from-default/#findComment-1024058 Share on other sites More sharing options...
sprint10s Posted March 10, 2010 Author Share Posted March 10, 2010 Sorry for the new post, that worked thank you so much for everyone's help, i think that was the biggest problem was i had the column in ' ' which turned it into a string. Thanks again and sorry for the multiple post. Quote Link to comment https://forums.phpfreaks.com/topic/194728-displaying-date-different-from-default/#findComment-1024063 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.