在PHP中显示当前时间戳
我在PostgreSQL数据库中插入了在PHP中显示当前时间戳,php,postgresql,Php,Postgresql,我在PostgreSQL数据库中插入了current\u时间戳。我想在PHP程序中显示日期和时间,但我所做的任何事情都不能显示时间 我使用了-$date=date(“m-d-Y h-I-s”,strotime($row['status\u date')) 日期正常,但时间始终显示为12-00-00。如果您有php5.4,可以运行以下脚本: <?php echo (new DateTime())->getTimestamp(); 可能$row['status\u date']没有时间
current\u时间戳。我想在PHP程序中显示日期和时间,但我所做的任何事情都不能显示时间
我使用了-$date=date(“m-d-Y h-I-s”,strotime($row['status\u date'))代码>
日期正常,但时间始终显示为12-00-00。如果您有php5.4,可以运行以下脚本:
<?php echo (new DateTime())->getTimestamp();
可能$row['status\u date']没有时间。$row['status\u date']的可能输出为2013-10-04 00:00:00。您可以尝试以下方法:
$date = date("m-d-Y h:i A", strtotime($row['status_date']));
您能告诉我们$row['status\u date']的值是多少吗?当您插入时,您可能会弄错。检查代码,否则也会发布该代码。可能重复的$row['status_date']显示10-04-2013 12:00:00。结果是10-04-2013 12:00 AM.echo(new DateTime())->getTimestamp();抛出一个错误。应为“,”。您有哪个版本的php?
<?php
$date = new DateTime();
echo $date->getTimestamp();
$date = date("m-d-Y h:i A", strtotime($row['status_date']));