| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Recurring Date Example |
| 5 |
* |
| 6 |
* Recurring date examples with RRULE property |
| 7 |
* |
| 8 |
*/ |
| 9 |
|
| 10 |
require_once("../zapcallib.php"); |
| 11 |
|
| 12 |
$examples = |
| 13 |
array( |
| 14 |
array( |
| 15 |
"name" => "Abraham Lincon's birthday", |
| 16 |
"date" => "2015-02-12", |
| 17 |
"rule" => "FREQ=YEARLY;INTERVAL=1;BYMONTH=2;BYMONTHDAY=12" |
| 18 |
), |
| 19 |
|
| 20 |
array( |
| 21 |
"name" => "Start of U.S. Supreme Court Session (1st Monday in October)", |
| 22 |
"date" => "2015-10-01", |
| 23 |
"rule" => "FREQ=YEARLY;INTERVAL=1;BYMONTH=10;BYDAY=1MO" |
| 24 |
) |
| 25 |
); |
| 26 |
|
| 27 |
// Use maxdate to limit # of infinitely repeating events |
| 28 |
$maxdate = strtotime("2021-01-01"); |
| 29 |
|
| 30 |
foreach($examples as $example) |
| 31 |
{ |
| 32 |
echo $example["name"] . ":\n"; |
| 33 |
$rd = new ZCRecurringDate($example["rule"],strtotime($example["date"])); |
| 34 |
$dates = $rd->getDates($maxdate); |
| 35 |
foreach($dates as $d) |
| 36 |
{ |
| 37 |
echo " " . date('l, F j, Y ',$d) . "\n"; |
| 38 |
} |
| 39 |
echo "\n"; |
| 40 |
} |
| 41 |
|