drrkgbm6851 2010-04-26 01:28
浏览 106
已采纳

date()显示在1969年12月

$sql = "SELECT * FROM news ORDER BY `news_id` DESC LIMIT 1";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);
$date = $row['time_posted'];
echo "<i> " .date("Y/m/d", $date) . "</i>: ";

I used timestamp in mysql.

  • 写回答

2条回答 默认 最新

  • dongxiz5342 2010-04-26 01:34
    关注
    date('Y/m/d', strtotime($date));
    

    TIMESTAMP columns are not displayed as unix timestamps (anymore).

    TIMESTAMP columns are displayed in the same format as DATETIME columns. In other words, the display width is fixed at 19 characters, and the format is 'YYYY-MM-DD HH:MM:SS'.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?