date() is showing December 1969
$sql = "SELECT * FROM news ORDER BY `news_id` DESC LIMIT 1";
$result = mysql_query($sql) or die(mysql_er开发者_开发问答ror());
$row = mysql_fetch_assoc($result);
$date = $row['time_posted'];
echo "<i> " .date("Y/m/d", $date) . "</i>: ";
I used timestamp in mysql.
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'.
The UNIX epoch was at January 1, 1970 at exactly midnight UTC. If you live in a timezone behind UTC, timestamp 0 will show up sometime in the evening of December 31, 1969. ($date
is most likely 0)
精彩评论