Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中显示当前时间戳_Php_Postgresql - Fatal编程技术网

在PHP中显示当前时间戳

在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']没有时间

我在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']没有时间。$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']));