|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39971 pg_insert / pg_update do not allow now() to be used for timestamp fields
Submitted: 2006-12-28 02:06 UTC Modified: 2006-12-29 00:35 UTC
From: epotocko at gmail dot com Assigned: iliaa (profile)
Status: Closed Package: PostgreSQL related
PHP Version: 5.2.0 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
21 + 20 = ?
Subscribe to this entry?

 [2006-12-28 02:06 UTC] epotocko at gmail dot com
The pg_insert and pg_update functions will not accept now() as a valid value for timestamp fields.

Reproduce code:
// Assumes the following table exists:
  CREATE TABLE timestamp_test
    id serial NOT NULL, 
    mytime timestamp NOT NULL,
    CONSTRAINT timestamp_test_pkey PRIMARY KEY (id)

$dbConn = pg_connect();

$values = array('mytime' => 'now()');
pg_insert($dbConn, 'timestamp_test', $values);

$ids = array('id' => 1);
$fields = array('mytime' => 'now()');
pg_update($dbConn, 'timestamp_test', $fields, $ids);

Expected result:
Both the insert and the update should succeed.

Actual result:
Error Log:

PHP Notice:  pg_insert() [<a href=''></a>]: 'now()' does not match with '^([0-9]{4}[/-][0-9]{1,2}[/-][0-9]{1,2})([ \t]+(([0-9]{1,2}:[0-9]{1,2}){1}(:[0-9]{1,2}){0,1}(\.[0-9]+){0,1}([ \t]*([+-][0-9]{1,2}(:[0-9]{1,2}){0,1}|[a-zA-Z]{1,5})){0,1})){0,1}$' 

PHP Notice:  pg_insert() [<a href=''></a>]: Expects NULL or string for PostgreSQL timestamp field (mytime)

PHP Notice:  pg_update() [<a href=''></a>]: 'now()' does not match with '^([0-9]{4}[/-][0-9]{1,2}[/-][0-9]{1,2})([ \t]+(([0-9]{1,2}:[0-9]{1,2}){1}(:[0-9]{1,2}){0,1}(\.[0-9]+){0,1}([ \t]*([+-][0-9]{1,2}(:[0-9]{1,2}){0,1}|[a-zA-Z]{1,5})){0,1})){0,1}$' 

PHP Notice:  pg_update() [<a href=''></a>]: Expects NULL or string for PostgreSQL timestamp field (mytime) 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-28 15:14 UTC]
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

The error comes from PostgreSQL, PHP simply relays it to you.
 [2006-12-28 15:32 UTC]
The error comes from php_pgsql_convert(), see ext/pgsql/pgsql.c:4975.
 [2006-12-29 00:35 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Apr 22 00:01:23 2021 UTC