Sorrow Posted October 30, 2008 Share Posted October 30, 2008 Hi here is my problem. I have a date in my database in the format (2008-11-30) and for each entry that I have in my database when it is displayed on my webpage I need to have it displayed like That (November 30 2008) I have found How to get the format of the date change SELECT MONTHNAME(TestDate), DAYOFMONTH(TestDate), YEAR(TestDate) FROM Test But I cant figure out how to use it In this code(it has to be at the release date replacing {$row['NPReldate']}) since each entry are displayed one after the other on the same page <?php include 'opendb.php'; $query = "SELECT * FROM NowPlaying ORDER BY NPIndex DESC"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo " <font face = 'Verdana'><table width='350' border = '0' cellspacing='5'> <tr> <td width = '300' colspan = '2'><center><b>{$row['NPTitle']}</center> </td></tr><tr><br> <td rowspan = '5'><a href = '{$row['NPCase']}'><img src='{$row['NPCase']}' width='125' height='200' border = '0' align='top'></a></td> <td> <tr><td><b>Director : </b>{$row['NPDirector']}<br></td></tr> <tr><td><b>Writers : </b>{$row['NPWriters']}<br></td></tr> <tr><td><b>Production Company : </b>{$row['NPStudio']}<br></td></tr> <tr><td><b>Actors : </b>{$row['NPActors']}<br></td></tr> <tr><td colspan = '2'><b>Release Date : </b>{$row['NPReldate']}<br></td></tr> </td> </tr> <tr> <td width ='300' colspan='2' align='justify'> Plot : "; echo nl2br($row['NPPlot']); echo "</td></tr><tr><td></td></tr> </table><br><br><br></font> "; } mysql_close($con); ?> Anyone has any Idea pls Thank you in advance Link to comment https://forums.phpfreaks.com/topic/130677-date-problem-pls-help/ Share on other sites More sharing options...
crochk Posted October 30, 2008 Share Posted October 30, 2008 I could be missing something, but why don't you just put it into your database in the correct format. Link to comment https://forums.phpfreaks.com/topic/130677-date-problem-pls-help/#findComment-678125 Share on other sites More sharing options...
xtopolis Posted October 30, 2008 Share Posted October 30, 2008 Use DATE_FORMAT(column,'%format %format') (etc) , instead. http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format should be DATE_FORMAT(TestDate,'%M %e %Y') fyi, his column is in the 'correct' format. Link to comment https://forums.phpfreaks.com/topic/130677-date-problem-pls-help/#findComment-678131 Share on other sites More sharing options...
Sorrow Posted October 30, 2008 Author Share Posted October 30, 2008 Ok thank you I get that but how do I use this with the current query that I have so I could get the date displayed with the rest of the infos?? Link to comment https://forums.phpfreaks.com/topic/130677-date-problem-pls-help/#findComment-678136 Share on other sites More sharing options...
xtopolis Posted October 30, 2008 Share Posted October 30, 2008 Don't SELECT * Do SELECT columnname, columnname, etc, etc, DATE_FORMAT(NPReldate,'%M %e %Y') FROM ... etc That's afaik. * shouldn't be used unless you really are selecting all columns from the database. And I don't know how you would SELECT * and append a format to one of the columns. Everything else should be fine as is. Link to comment https://forums.phpfreaks.com/topic/130677-date-problem-pls-help/#findComment-678137 Share on other sites More sharing options...
Sorrow Posted October 30, 2008 Author Share Posted October 30, 2008 Ok i got this to work but in my code <tr><td colspan = '2'><b>Release Date : </b>{$row['NPReldate']}<br></td></tr> But What do I replace {$row['NPReldate']} with because I tried {$row['NPReldate']} and DATE_FORMAT( NPRelDate, ' %M %D %Y' ) also and it is not working Link to comment https://forums.phpfreaks.com/topic/130677-date-problem-pls-help/#findComment-678146 Share on other sites More sharing options...
xtopolis Posted October 30, 2008 Share Posted October 30, 2008 Make it DATE_FORMAT( NPRelDate, ' %M %D %Y' ) AS 'NPRelDate' (sorry, I thought you would know to do that) Link to comment https://forums.phpfreaks.com/topic/130677-date-problem-pls-help/#findComment-678152 Share on other sites More sharing options...
Sorrow Posted October 30, 2008 Author Share Posted October 30, 2008 thank you I used to know it but I havent programmed for a couple of years lol thank you man Link to comment https://forums.phpfreaks.com/topic/130677-date-problem-pls-help/#findComment-678168 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.