douhui3760 2015-03-25 13:38
浏览 73
已采纳

SQL时间戳 - > 1970

I want to output the time, when my form saves a input. Here is my code, my DB settings and my output. I hope someone can help me. I am new in PHP and SQL and I am very proud so far. :)

<?php 
$dbLink=mysql_connect('','',''); 
mysql_select_db('',$dbLink); 

$abfrage='SELECT * FROM links ORDER BY Zeit DESC'; 
$ergebnis=mysql_query($abfrage); 
?>

<?php
while($row=mysql_fetch_object($ergebnis))
{
echo "<tr>";
echo "<td>".date("d.m.Y",$row->Zeit)."</td>";
echo "<td><a href='".$row->url."' target='_blank'>".$row->text."</a></td>";
echo "<td>".$row->kategorie."</td>";
echo "</tr>";
}
?>

Here are my table settings

This is the time in my table

This is how it looks at my website

  • 写回答

1条回答 默认 最新

  • drjgk44268 2015-03-25 13:40
    关注

    date() requires a Unix Timestamp as its second parameter. You need to convert that MySQL datetime value into a Unix Timestamp using strtotime()before date() can transform it:

    echo "<td>".date("d.m.Y",strtotime($row->Zeit))."</td>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?