使用php by Row显示12小时格式

时间:2014-08-18 10:58:33

标签: php mysql

我试图显示/回显列Modified_out By Row的12小时格式。

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>

感谢。

5 个答案:

答案 0 :(得分:0)

您可能应该以同样的方式将对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>
";

答案 1 :(得分:0)

<td>".date('m/d/y g:i A',$row['modification_out'])."</td>

答案 2 :(得分:0)

实际上,你的语法是错误的。请参阅以下内容:(注意:这假定$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>
";

答案 3 :(得分:0)

更改

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>
";

答案 4 :(得分:0)

要解决此问题Notice: A non well formed numeric value encountered在$ row [&#39; modification_out&#39;]中添加strtotime() function以将英文文本日期时间解析为Unix时间戳,那么它将是格式正确的日期值< / p>

 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>
    ";