xref: /php-src/ext/date/tests/bug54340.phpt (revision 7aacc705)
1--TEST--
2Bug #54340 (DateTime::add() method bug)
3--INI--
4date.timezone=UTC
5--FILE--
6<?php
7$interval = new DateInterval('P1D');
8
9$dt = new DateTime('first day of January 2011');
10var_dump($dt);
11
12$dt->add($interval);
13var_dump($dt);
14
15$dt = new DateTime('first day of January 2011');
16
17$dt->sub($interval);
18var_dump($dt);
19?>
20--EXPECT--
21object(DateTime)#2 (3) {
22  ["date"]=>
23  string(26) "2011-01-01 00:00:00.000000"
24  ["timezone_type"]=>
25  int(3)
26  ["timezone"]=>
27  string(3) "UTC"
28}
29object(DateTime)#2 (3) {
30  ["date"]=>
31  string(26) "2011-01-02 00:00:00.000000"
32  ["timezone_type"]=>
33  int(3)
34  ["timezone"]=>
35  string(3) "UTC"
36}
37object(DateTime)#3 (3) {
38  ["date"]=>
39  string(26) "2010-12-31 00:00:00.000000"
40  ["timezone_type"]=>
41  int(3)
42  ["timezone"]=>
43  string(3) "UTC"
44}
45