edoplaza Posted October 31, 2009 Report Share Posted October 31, 2009 (edited) Home Biography Critics Repertory CDs Live Recordings Videos Publications Gallery Events Contact Events <?php do { ?> <?php echo $row_RsEventos['titulo']; ?> Date: <?php echo $row_RsEventos['fecha']; ?> Place: <?php echo $row_RsEventos['lugar']; ?> Time: <?php echo $row_RsEventos['hora']; ?> <?php echo $row_RsEventos['comentarios']; ?> <?php } while ($row_RsEventos = mysql_fetch_assoc($RsEventos)); ?> home | administration | contact Copyright ? Germ?n Marcano 2009 Edited October 31, 2009 by edoplaza Quote Link to comment Share on other sites More sharing options...
Wickham Posted October 31, 2009 Report Share Posted October 31, 2009 All the date codes are here:- http://php.net/manual/en/function.date.php Use d-m-Y for dd-mm-yyyy Quote Link to comment Share on other sites More sharing options...
Wickham Posted November 1, 2009 Report Share Posted November 1, 2009 (edited) EDIT - go to my edit at the bottom of the post. No one else has answered so I will offer a little more information, but my PHP and MySQL knowledge is not much; I was hoping falkencreative would answer the question properly. Your page display has this code Date: <?php echo $row_RsEventos['fecha']; ?> which just repeats what is in the database field 'fecha', so perhaps one solution is to change the format in the database, not in the PHP code which displays it on the page. If you look at this example:- http://www.wickham43.net/formphptomysql.php You will see a form for submission of data which has a date already inserted with a date format echo date("d M Y"); ?> and the database stores this as text (Field: Date; Type: text) and the display of the data in the table at the bottom of the page just shows the text of the date that the database stored. You can see from the dates in the display that the format changes half way down because I changed the date format in the top submission form. My Date is stored as text but you probably have the database storing date in a date format. You don't show how you get the dates into the database; either change the date format in the form you use to input into the database or go into the database and change the date format there. MySQL date is always stored in the YYYY-MM-DD format and it's complicated to reformat it so it may be easier to change the database Type to Text and then the PHP for the page should output the same text as the database. Editing the Type for the Field in MySQL is relatively simple and you would then have to edit the previous database entries manually but future date entries as text would be repeated as text by the PHP code. I expect that there is a way to take the date format from the database and change it to another format with PHP for the table display but falkencreative will have to answer that. EDIT: I've been experimenting and this code worked for me:- date('d-m-Y', strtotime($row['fecha'])) but I was testing with a different database and a different form so where you have <?php echo $row_RsEventos['fecha']; ?> in your PHP file I think you need <?php echo date('d-m-Y', strtotime($row['fecha'])); ?> Try it. Edited November 1, 2009 by Wickham Quote Link to comment Share on other sites More sharing options...
edoplaza Posted November 2, 2009 Author Report Share Posted November 2, 2009 (edited) <?php echo $row_Rsprueba['fecha']; ?> Edited November 2, 2009 by edoplaza Quote Link to comment Share on other sites More sharing options...
edoplaza Posted November 5, 2009 Author Report Share Posted November 5, 2009 (edited) Finally, I found a solution: I was trying to use the DATE_FORMAT function, but it didn't work (still don't know why) I then changed this: echo $row_RsEvents['column_date']; Into this: $formatted_date= $row_RsEvents['column_date']; echo date("d-m-Y",strtotime($formatted_date)); and it works perfectly Cheers, Eduardo Edit: Sorry Wickham, I didn't see your last edit. I am glad we both came to the same solution! (but yours is better than mine ) Edited November 5, 2009 by edoplaza 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.
Note: Your post will require moderator approval before it will be visible.