使用php按行显示12小时格式

使用php按行显示12小时格式,php,mysql,Php,Mysql,我正在尝试按行显示/回显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&g

我正在尝试按行显示/回显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>
";

谢谢。

您可能应该以同样的方式连接对
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>
";
echo”
“$row['username']”
“$row['details_out']”
.date(“m/d/y g:IA”,$row['modification_out'])
“$row['otherout']”
";
”。日期('m/d/y g:IA',$row['modification_out'])

实际上,您的语法是错误的。请参见以下内容:(注意:假设
$row['modification\u out']
是unix时间戳)

echo”
“$row['username']”
“$row['details_out']”
.date(“m/d/y g:IA”,$row['modification_out'])
“$row['otherout']”
";
更改

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”
“$row['username']”
“$row['details_out']”
日期(“m/d/y g:i A”,“$行['modification_out'.]””
“$row['otherout']”
";

echo”
“$row['username']”
“$row['details_out']”
.date('m/d/y g:i A',$row['modification_out'])
“$row['otherout']”
";

要解决此问题,请注意:在$row['modification_out']中遇到格式不正确的数值
添加
strotime()函数
要将英文文本日期时间解析为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>
    ";
echo”
“$row['username']”
“$row['details_out']”
.date(“m/d/y g:i A”,strottime($row['modification_out']))
“$row['otherout']”
";

您必须更加具体。您的代码有什么问题?它应该正常工作。输出是什么?所需的输出是什么?行的内容是什么?它将显示日期和时间(12小时格式)@LeslieTan看到我的答案了吗?它肯定会解决你的问题。先生,这是一个问题。在遇到一个格式不正确的数值时遇到一个格式不正确的数值-错误,
$row['modification\u out']
的类型是什么?您可以使用
gettype($row['modification\u']);
我只是想出来,谢谢您。”.日期(“m/d/y g:i A”,STROTIME($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>
";
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", strtotime($row['modification_out']))."</td>

    <td><center>".$row['otherout']."</center></td>
    </td>
    </tr>
    ";