xref: /PHP-8.0/ext/date/tests/bug44562.phpt (revision 8e8a277b)
1--TEST--
2Bug #44562 (Creating instance of DatePeriod crashes)
3--FILE--
4<?php
5date_default_timezone_set('Europe/Oslo');
6
7try {
8    $dp = new DatePeriod('2D');
9} catch (Exception $e) {
10    echo $e->getMessage(), "\n";
11}
12
13$begin = new DateTime( "2008-07-20T22:44:53+0200" );
14$interval = DateInterval::createFromDateString( "1 day" );
15
16$dp = new DatePeriod( $begin, $interval, 10 );
17foreach ( $dp as $d )
18{
19    var_dump ($d->format( DATE_ISO8601 ) );
20}
21
22?>
23--EXPECT--
24DatePeriod::__construct(): Unknown or bad format (2D)
25string(24) "2008-07-20T22:44:53+0200"
26string(24) "2008-07-21T22:44:53+0200"
27string(24) "2008-07-22T22:44:53+0200"
28string(24) "2008-07-23T22:44:53+0200"
29string(24) "2008-07-24T22:44:53+0200"
30string(24) "2008-07-25T22:44:53+0200"
31string(24) "2008-07-26T22:44:53+0200"
32string(24) "2008-07-27T22:44:53+0200"
33string(24) "2008-07-28T22:44:53+0200"
34string(24) "2008-07-29T22:44:53+0200"
35string(24) "2008-07-30T22:44:53+0200"
36