xref: /PHP-8.4/ext/pgsql/tests/bug71062.phpt (revision c15988aa)
1--TEST--
2Bug #71062 pg_convert() doesn't accept ISO 8601 for datatype timestamp
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php include("inc/skipif.inc"); ?>
7--FILE--
8<?php
9
10include('inc/config.inc');
11
12$db = pg_connect($conn_str);
13
14$table = "public.test_table_bug71062_bug71062";
15
16pg_query($db, "CREATE TABLE $table ( test_field TIMESTAMPTZ )");
17
18// ISO 8601 (with 'T' between date and time)
19$date_string_php_iso8601 = date_create('8 Dec 2015 5:38')->format(DateTime::ISO8601);
20
21// ISO 8601 with the 'T' removed
22$modified_format = 'Y-m-d H:i:sO';
23$date_string_modified_iso8601 = date_create('8 Dec 2015 5:38')->format($modified_format);
24
25printf("trying format %s \n", DateTime::ISO8601);
26pg_convert($db, $table, ['test_field' => $date_string_php_iso8601]);
27
28printf("trying format %s \n", $modified_format);
29pg_convert($db, $table, ['test_field' => $date_string_modified_iso8601]);
30
31print "done\n";
32
33?>
34==OK==
35--CLEAN--
36<?php
37require_once('inc/config.inc');
38$db = @pg_connect($conn_str);
39$table = "public.test_table_bug71062_bug71062";
40
41pg_query($db, "DROP TABLE IF EXISTS $table");
42?>
43--EXPECT--
44trying format Y-m-d\TH:i:sO
45trying format Y-m-d H:i:sO
46done
47==OK==
48