tplaner / When

PHP Date Recursion library
https://github.com/tplaner/When
MIT License
513 stars 96 forks source link

weekly every 2 or 3 or 4th week on mo, tu, we not possible? #91

Closed CLutz86 closed 3 years ago

CLutz86 commented 3 years ago

hi there,

I'm trying to get dates of the following scenario, but always getting "undefined index" in When.php line 677. $when->startDate(now())->freq("weekly")->interval(3)->byday('mo,tu,we')

This is working perfectly, but if I choose interval > 1 then it doesn't work $when->startDate(now())->freq("weekly")->interval(1)->byday('mo,tu,we')

thanks in advance

tplaner commented 3 years ago

Make sure you have the latest version of When installed (v3.1.5).

I tested with this code, and it seems to work fine:

use Carbon\Carbon;
use When\When;

function now($tz = null)
{
    return Carbon::now($tz);
}

$when = new When();
$when->RFC5545_COMPLIANT = When::IGNORE;

$when->startDate(now())->freq("weekly")->interval(3)->byday('mo,tu,we');

$when->generateOccurrences();

print_r($when->occurrences);
CLutz86 commented 3 years ago

thx. Works like a charm :)