|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchespg_convert_fix_iso_8601 (last revision 2015-12-08 14:20 UTC by denver at timothy dot io)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-04-15 11:42 UTC] ab@php.net
[2016-04-15 11:42 UTC] ab@php.net
-Status: Open
+Status: Closed
[2016-07-20 11:32 UTC] davey@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 20 19:00:01 2025 UTC |
Description: ------------ pg_convert() does not accept an ISO 8601 date/time string, but will if the character "T" is replaced with whitespace. This is inconsistent with the constant DateTime::ISO8601 and date("c"). I believe if the regex in pgsql.c for case PG_TIMESTAMP (line 6165) can be improved (see patch). Test script: --------------- $db = pg_connect("dbname=test user=test"); pg_query($db, "CREATE TABLE public.test_table ( test_field TIMESTAMPTZ )"); // ISO 8601 (with 'T' between date and time) $date_string_php_iso8601 = date_create('8 Dec 2015 5:38')->format(DateTime::ISO8601); // ISO 8601 with the 'T' removed $modified_format = 'Y-m-d H:i:sO'; $date_string_modified_iso8601 = date_create('8 Dec 2015 5:38')->format($modified_format); printf("trying format %s \n", DateTime::ISO8601); pg_convert($db, 'public.test_table', ['test_field' => $date_string_php_iso8601]); printf("trying format %s \n", $modified_format); pg_convert($db, 'public.test_table', ['test_field' => $date_string_modified_iso8601]); print "done\n"; pg_query($db, "DROP TABLE test_table"); Expected result: ---------------- trying format Y-m-d\TH:i:sO trying format Y-m-d H:i:sO done Actual result: -------------- trying format Y-m-d\TH:i:sO PHP Notice: pg_convert(): Expects NULL or string for PostgreSQL timestamptz field (test_field) in /Users/dlt/Desktop/bug.php on line 16 Notice: pg_convert(): Expects NULL or string for PostgreSQL timestamptz field (test_field) in /Users/dlt/Desktop/bug.php on line 16 trying format Y-m-d H:i:sO done