开发者

date() is showing December 1969

开发者 https://www.devze.com 2022-12-28 07:49 出处:网络
$sql = \"SELECT * FROM news ORDER BY `news_id` DESC LIMIT 1\"; $result = mysql_query($sql) or die(mysql_er开发者_开发问答ror());
$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)

0

精彩评论

暂无评论...
验证码 换一张
取 消