My PHP script will work for several seconds, and I need to get real timestamp from Postgres database anytime. But when I fetch current_timestamp from Postgres, it always return same value.
Here is my example script (using DBAL):
echo "DB:" . $dbal->fetchColumn("select current_timestamp") . PHP_EOL;
echo "PHP: " . date("Y-m-d H:i:s") . PHP_EOL;
sleep(3);
echo "DB:" . $dbal->fetchColumn("select current_timestamp") . PHP_EOL;
echo "PHP: " . date("Y-m-d H:i:s") . PHP_EOL;
sleep(3);
echo "DB:" . $dbal->fetchColumn("select current_timestamp") . PHP_EOL;
echo "PHP: " . date("Y-m-d H:i:s") . PHP_EOL;
Here is the output:
DB:2014-05-07 11:59:50.118+04
PHP: 2014-05-07 11:59:50
DB:2014-05-07 11:59:50.118+04
PHP: 2014-05-07 11:59:53
DB:2014-05-07 11:59:50.118+04
PHP: 2014-05-07 11:59:56
Postgres installed on local machine. Why it always returns same time? How to get real time?
I used now() function, there was same result. Postgres version: 9.3.4 x64. PHP version: 5.5.11
See Question&Answers more detail:os