im 尝试显示/回显 12 小时格式的列modification_out按行。
while($row=mysql_fetch_array($raw_results)){
$username=$row['username'];
$details=$row['details_out'];
$details=$row['otherout'];
$modification_out=$row['modification_out'];
我在这里遇到了麻烦:
echo "
<tr>
<td><center>".$row['username']."</center></td>
<td><center>".$row['details_out']."</center></td>
<td>date("m/d/y g:i A",".$row['modification_out'].")"</td>
<td><center>".$row['otherout']."</center></td>
</td>
</tr>
";
我收到此错误:Notice: A non well formed numeric value encountered in
谢谢所有的回复,伙计们,我只是想出答案。
<td>".date("m/d/y g:i A", strtotime($row['modification_out']))."</td>
谢谢。
您可能应该以相同的方式连接对date()
的调用 - 这在您的代码中看起来很奇怪。
echo "
<tr>
<td><center>".$row['username']."</center></td>
<td><center>".$row['details_out']."</center></td>
<td>".date("m/d/y g:i A", $row['modification_out'])."</td>
<td><center>".$row['otherout']."</center></td>
</td>
</tr>
";
<td>".date('m/d/y g:i A',$row['modification_out'])."</td>
实际上,你的语法是错误的。见下文:(注意:这假设$row['modification_out']
是一个 unix 时间戳(
echo "
<tr>
<td><center>".$row['username']."</center></td>
<td><center>".$row['details_out']."</center></td>
<td>".date("m/d/y g:i A", $row['modification_out'])."</td>
<td><center>".$row['otherout']."</center></td>
</td>
</tr>
";
更改
echo "
<tr>
<td><center>".$row['username']."</center></td>
<td><center>".$row['details_out']."</center></td>
<td>date("m/d/y g:i A",".$row['modification_out'].")"</td>
<td><center>".$row['otherout']."</center></td>
</td>
</tr>
";
自
echo "
<tr>
<td><center>".$row['username']."</center></td>
<td><center>".$row['details_out']."</center></td>
<td>" . date('m/d/y g:i A',$row['modification_out']) . "</td>
<td><center>".$row['otherout']."</center></td>
</td>
</tr>
";
要解决此问题Notice: A non well formed numeric value encountered
在 $row['modification_out'] 中添加strtotime() function
,将英语文本日期时间解析为 Unix 时间戳,然后它将是格式正确的日期值
echo "
<tr>
<td><center>".$row['username']."</center></td>
<td><center>".$row['details_out']."</center></td>
<td>".date("m/d/y g:i A", strtotime($row['modification_out']))."</td>
<td><center>".$row['otherout']."</center></td>
</td>
</tr>
";