xref: /PHP-5.3/ext/date/tests/date_period.phpt (revision a9e5e222)
1--TEST--
2DatePeriod
3--FILE--
4<?php
5date_default_timezone_set('UTC');
6$db = new DateTime( '2008-01-01' );
7$de = new DateTime( '2008-12-31' );
8$di = DateInterval::createFromDateString( 'first day of next month' );
9
10foreach ( new DatePeriod( $db, $di, $de ) as $dt )
11{
12    echo $dt->modify( "3 tuesday" )->format( "l Y-m-d\n" );
13}
14?>
15
16<?php
17$db = new DateTime( '2007-12-31' );
18$de = new DateTime( '2009-12-31 23:59:59' );
19$di = DateInterval::createFromDateString( 'last thursday of next month' );
20
21foreach ( new DatePeriod( $db, $di, $de, DatePeriod::EXCLUDE_START_DATE ) as $dt )
22{
23    echo $dt->format( "l Y-m-d H:i:s\n" );
24}
25?>
26--EXPECT--
27Tuesday 2008-01-15
28Tuesday 2008-02-19
29Tuesday 2008-03-18
30Tuesday 2008-04-15
31Tuesday 2008-05-20
32Tuesday 2008-06-17
33Tuesday 2008-07-15
34Tuesday 2008-08-19
35Tuesday 2008-09-16
36Tuesday 2008-10-21
37Tuesday 2008-11-18
38Tuesday 2008-12-16
39
40Thursday 2008-01-31 00:00:00
41Thursday 2008-02-28 00:00:00
42Thursday 2008-03-27 00:00:00
43Thursday 2008-04-24 00:00:00
44Thursday 2008-05-29 00:00:00
45Thursday 2008-06-26 00:00:00
46Thursday 2008-07-31 00:00:00
47Thursday 2008-08-28 00:00:00
48Thursday 2008-09-25 00:00:00
49Thursday 2008-10-30 00:00:00
50Thursday 2008-11-27 00:00:00
51Thursday 2008-12-25 00:00:00
52Thursday 2009-01-29 00:00:00
53Thursday 2009-02-26 00:00:00
54Thursday 2009-03-26 00:00:00
55Thursday 2009-04-30 00:00:00
56Thursday 2009-05-28 00:00:00
57Thursday 2009-06-25 00:00:00
58Thursday 2009-07-30 00:00:00
59Thursday 2009-08-27 00:00:00
60Thursday 2009-09-24 00:00:00
61Thursday 2009-10-29 00:00:00
62Thursday 2009-11-26 00:00:00
63Thursday 2009-12-31 00:00:00
64