summaryrefslogtreecommitdiff
path: root/ext/date/tests/date_add_basic.phpt
blob: 40e4d388677a1cf15ef9b30c4433b2f2f2b0b910 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--TEST--
Test date_add() function : basic functionality
--CREDITS--
Felix De Vliegher <felix.devliegher@gmail.com>
--FILE--
<?php
date_default_timezone_set('UTC');
echo "*** Testing date_add() : basic functionality ***\n";

// Initialise all required variables
$startDate = '2008-01-01 12:25';
$format = 'Y-m-d H:i:s';
$intervals = array(
    'P3Y6M4DT12H30M5S',
    'P0D',
    'P2DT1M',
    'P1Y2MT23H43M150S'
);

$d = new DateTime($startDate);
var_dump( $d->format($format) );

foreach($intervals as $interval) {
    date_add($d, new DateInterval($interval) );
    var_dump( $d->format($format) );
}

?>
--EXPECT--
*** Testing date_add() : basic functionality ***
string(19) "2008-01-01 12:25:00"
string(19) "2011-07-06 00:55:05"
string(19) "2011-07-06 00:55:05"
string(19) "2011-07-08 00:56:05"
string(19) "2012-09-09 00:41:35"