How to convert MySQL timestamp to PHP date type

Let’s say you have the following PHP code that extracts the date from the times table in your MySQL database. The date is of timestamp type which has the following format: ‘YYYY-MM-DD HH:MM:SS’ or ‘2008-10-05 21:34:02.’

  1. $res = mysql_query("SELECT date FROM times;");
  2. while ( $row = mysql_fetch_array($res) ) {
  3.    echo $row['date'] . "<br />";
  4. }

Continue reading How to convert MySQL timestamp to PHP date type