gastooon Posted January 20, 2014 Share Posted January 20, 2014 So I have a huge problem with probably a simple solution. But after hours of searching on google I gave up. Here is my problem... I have a date in my phpmyadmin that output like this 2014-01-20 but I want it to output like this 20 January, 2014. It's "event_startdate" and "event_enddate" that I want to change. Here is my code... $event_list = ""; $sql = mysql_query ("SELECT * FROM events ORDER BY event_startdate ASC"); $eventCount = mysql_num_rows($sql); // Count number of rows to outpout. if($eventCount > 0){ while($row = mysql_fetch_array($sql)){ $id = $row["id"]; $event_name = $row["event_name"]; $event_startdate = $row["event_startdate"]; $event_enddate = $row["event_enddate"]; $event_place = $row["event_place"]; $event_list .= ' <div class="eventlistpage"> <a href="event.php?id=' . $id .'"> <p id="eventNameBox">' . $event_name . '</p> <p>' . $event_startdate . '</p> <p>' . $event_enddate . '</p> <p>' . $event_place . '</p> </a> <div class="clear"></div> </div>'; } } else { } Quote Link to comment https://forums.phpfreaks.com/topic/285530-date-output-need-help/ Share on other sites More sharing options...
Solution Barand Posted January 20, 2014 Solution Share Posted January 20, 2014 (edited) echo date ('j F, Y', strtotime($row['event_date'])); or $dt = new DateTime($row['event_date']); echo $dt->format('j F, Y'); Edited January 20, 2014 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/285530-date-output-need-help/#findComment-1465897 Share on other sites More sharing options...
gastooon Posted January 20, 2014 Author Share Posted January 20, 2014 Haha, that is just stupid. Been circling around that for hours! Thanks alot!! Quote Link to comment https://forums.phpfreaks.com/topic/285530-date-output-need-help/#findComment-1465899 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.