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