How to reformat the date from a MYSQL database with php

By Chris on September 18, 2010 in php

To display a date retrieved from a recordset in a new format (In this case from a recordset ‘rs_news’):

  • <?php echo date(‘d M Y’, strtotime($row_rs_news[‘date’])); ?>

When inserting the date in your MySQL database from an update form it needs to be in the MySQL format yyyy-mm-dd. To update a record in this format use;

  • GetSQLValueString(date(‘Y-m-d’, strtotime($_POST[‘date’])), “date”));


Leave a reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.