如何使用mysql php更改查询中的日期格式[关闭]

        $displayQuery = mysql_query("SELECT SUM(product_price*quantity) AS total, deyt as da FROM cart GROUP BY deyt");

        while ($displayRow = mysql_fetch_array($displayQuery)){

        $total=$displayRow['total'];
        $date=$displayRow['da'];
        $date2 = date('M-d-Y', $date);
          echo "<tr>  <td> <a href='perday?date=".$displayRow['da']."'>".$date2." </td>";
          echo "      <td> ".$displayRow['total']." </td>";

        }      





 The output always
    _____________________________________
   | Jan 01, 1970       |       4631.00 |
   | Jan 01, 1970       |       4.00    |
   | Jan 01, 1970       |       4.00    |
   | Jan 01, 1970       |       25.00   |
   | Jan 01, 1970       |       115.00  |
   | Jan 01, 1970       |       944.00  |
   | Jan 01, 1970       |       250.00  |
   |____________________|_______________|

   I want like this
   ______________________________________
   | Jun 1, 2015        |       4631.00 |
   | Jun 5, 2015        |       4.00    |
   | Jun 8, 2015        |       4.00    |
   | Jul 10, 2015       |       25.00   |
   | Jul 11, 2015       |       115.00  |
   | Jul 20, 2015       |       944.00  |
   | Aug 1, 2015        |       250.00  |
   |____________________|_______________|

You need to pass unix timestamp in date function. Here is your solution. ( I assume that the datatype of deyt column is DATE )

$date=$displayRow['da'];
$date2 = date('M-d-Y', strtotime(str_replace('-', '/', $date)));