回显从数据库中获取的TIMESTAMP值,并使用jQuery进行显示


Echo a TIMESTAMP value taken from a database and display with jQuery

我正在查询数据库以检索输入项目的时间。此项目是TIMESTAMP。我将它从php返回到我的主页。当在html表中显示时间时,它会正确显示(即YYYY-MM-DD HH:MM:SS:MS)。但是,当我单击按钮用jQuery检查值时,页面只会提醒YYYY-MM-DD)。JS的Date()函数在这里似乎不合适,因为它返回当前时间。如有任何建议,我们将不胜感激。

预期警报:2013-11-20 02:04:43实际警报:2013-11-20

page1.php:

$('.content').on('click', '.remove_button', function(){
var clicked = $(this);
alert((clicked.val()));
});

page2.php:

$findMsg = mysqli_query($con,"SELECT (m.timeSent)AS time FROM MessageAdmin m");
while($row = mysqli_fetch_array($findMsg)){
    echo "<tr>";
    echo "<td>" .$row['time']."</td>";
    echo "<td><button class='remove_button' value=".$row['time'].">Delete</button></td>";
    echo "</tr>";       
}

您需要在value属性中的时间戳周围加引号,否则日期后的空格将终止值:

    echo "<td><button class='remove_button' value='".$row['time']."'>Delete</button></td>";