@ 2021-07-28T12:58:52Z <?php
$timezone = new DateTimeZone( "UTC" );
$fmj = DateInterval::createFromDateString( 'first Monday of January next year' );
//Monday from start 2019 only
$period = new DatePeriod( new DateTime( '2019-01-01 00:00:00.000000', $timezone ), $fmj, new DateTime( '2022-01-11 00:00:00.000000', $timezone ) );
//$period->current= new \DateTime('2019-05-06 00:00:00', new \DateTimeZone('UTC'));
$y = 0;
foreach ( $period as $dt ) {
$c[] = $period;
$display[$y++] = $dt->format( "l Y-m-d H:i:s" );
//stop total_recurrence
if( $y == 5 ) {
break;
}
}
$var = new DateTime( 'first monday of January', new DateTimeZone( "UTC" ));
$display[5] = $var->format( "l Y-m-d H:i:s" );
var_dump( $display, $fmj, $c);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.3.0 - 8.3.4 , 8.3.6 Fatal error: Uncaught DateMalformedIntervalStringException: String 'first Monday of January next year' contains non-relative elements in /in/uJpiU:4
Stack trace:
#0 /in/uJpiU(4): DateInterval::createFromDateString('first Monday of...')
#1 {main}
thrown in /in/uJpiU on line 4
Process exited with code 255 . Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Fatal error: Uncaught DateMalformedIntervalStringException: String 'first Monday of January next year' contains non-relative elements in /in/uJpiU:4
Stack trace:
#0 /in/uJpiU(4): DateInterval::createFromDateString('first Monday of...')
#1 {main}
thrown in /in/uJpiU on line 4
Process exited with code 255 . Output for 8.2.0 - 8.2.18 Warning: DateInterval::createFromDateString(): String 'first Monday of January next year' contains non-relative elements in /in/uJpiU on line 4
Fatal error: Uncaught TypeError: DatePeriod::__construct() accepts (DateTimeInterface, DateInterval, int [, int]), or (DateTimeInterface, DateInterval, DateTime [, int]), or (string [, int]) as arguments in /in/uJpiU:6
Stack trace:
#0 /in/uJpiU(6): DatePeriod->__construct(Object(DateTime), false, Object(DateTime))
#1 {main}
thrown in /in/uJpiU on line 6
Process exited with code 255 . Output for 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 array(5) {
[0]=>
string(27) "Tuesday 2019-01-01 00:00:00"
[1]=>
string(27) "Tuesday 2020-01-07 00:00:00"
[2]=>
string(29) "Wednesday 2021-01-06 00:00:00"
[3]=>
string(27) "Tuesday 2022-01-04 00:00:00"
[5]=>
string(26) "Monday 2021-01-04 00:00:00"
}
object(DateInterval)#2 (16) {
["y"]=>
int(1)
["m"]=>
int(0)
["d"]=>
int(0)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(1)
["weekday_behavior"]=>
int(1)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
bool(false)
["special_type"]=>
int(2)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(1)
["have_special_relative"]=>
int(1)
}
array(4) {
[0]=>
object(DatePeriod)#3 (6) {
["start"]=>
object(DateTime)#4 (3) {
["date"]=>
string(26) "2019-01-01 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["current"]=>
object(DateTime)#7 (3) {
["date"]=>
string(26) "2023-01-03 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["end"]=>
object(DateTime)#8 (3) {
["date"]=>
string(26) "2022-01-11 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["interval"]=>
object(DateInterval)#9 (16) {
["y"]=>
int(1)
["m"]=>
int(0)
["d"]=>
int(0)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(1)
["weekday_behavior"]=>
int(1)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
bool(false)
["special_type"]=>
int(2)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(1)
["have_special_relative"]=>
int(1)
}
["recurrences"]=>
int(1)
["include_start_date"]=>
bool(true)
}
[1]=>
object(DatePeriod)#3 (6) {
["start"]=>
object(DateTime)#10 (3) {
["date"]=>
string(26) "2019-01-01 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["current"]=>
object(DateTime)#4 (3) {
["date"]=>
string(26) "2023-01-03 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["end"]=>
object(DateTime)#7 (3) {
["date"]=>
string(26) "2022-01-11 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["interval"]=>
object(DateInterval)#8 (16) {
["y"]=>
int(1)
["m"]=>
int(0)
["d"]=>
int(0)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(1)
["weekday_behavior"]=>
int(1)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
bool(false)
["special_type"]=>
int(2)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(1)
["have_special_relative"]=>
int(1)
}
["recurrences"]=>
int(1)
["include_start_date"]=>
bool(true)
}
[2]=>
object(DatePeriod)#3 (6) {
["start"]=>
object(DateTime)#9 (3) {
["date"]=>
string(26) "2019-01-01 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["current"]=>
object(DateTime)#10 (3) {
["date"]=>
string(26) "2023-01-03 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["end"]=>
object(DateTime)#4 (3) {
["date"]=>
string(26) "2022-01-11 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["interval"]=>
object(DateInterval)#7 (16) {
["y"]=>
int(1)
["m"]=>
int(0)
["d"]=>
int(0)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(1)
["weekday_behavior"]=>
int(1)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
bool(false)
["special_type"]=>
int(2)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(1)
["have_special_relative"]=>
int(1)
}
["recurrences"]=>
int(1)
["include_start_date"]=>
bool(true)
}
[3]=>
object(DatePeriod)#3 (6) {
["start"]=>
object(DateTime)#8 (3) {
["date"]=>
string(26) "2019-01-01 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["current"]=>
object(DateTime)#9 (3) {
["date"]=>
string(26) "2023-01-03 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["end"]=>
object(DateTime)#10 (3) {
["date"]=>
string(26) "2022-01-11 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
["interval"]=>
object(DateInterval)#4 (16) {
["y"]=>
int(1)
["m"]=>
int(0)
["d"]=>
int(0)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(1)
["weekday_behavior"]=>
int(1)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
bool(false)
["special_type"]=>
int(2)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(1)
["have_special_relative"]=>
int(1)
}
["recurrences"]=>
int(1)
["include_start_date"]=>
bool(true)
}
}
preferences:dark mode live preview
192.58 ms | 414 KiB | 156 Q