xref: /PHP-5.3/ext/date/tests/bug54340.phpt (revision 334d2df8)
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--EXPECT--
20object(DateTime)#2 (3) {
21  ["date"]=>
22  string(19) "2011-01-01 00:00:00"
23  ["timezone_type"]=>
24  int(3)
25  ["timezone"]=>
26  string(3) "UTC"
27}
28object(DateTime)#2 (3) {
29  ["date"]=>
30  string(19) "2011-01-02 00:00:00"
31  ["timezone_type"]=>
32  int(3)
33  ["timezone"]=>
34  string(3) "UTC"
35}
36object(DateTime)#3 (3) {
37  ["date"]=>
38  string(19) "2010-12-31 00:00:00"
39  ["timezone_type"]=>
40  int(3)
41  ["timezone"]=>
42  string(3) "UTC"
43}
44