@ 2016-01-05T18:45:07Z <?php
$firstAvailableCount = 100;
$slice = 'monthly';
$countData = array();
$startDateTime = new DateTime("2016-01-01");
$endDateTime = new DateTime("2016-02-02");
fillCountMapPeriod($startDateTime,$endDateTime,$countData,$firstAvailableCount,$slice);
function fillCountMapPeriod( DateTime $startDateTime, DateTime $endDateTime, array $countData, $firstAvailableCount, $slice) {
if($slice == 'monthly') {
$interval = new DateInterval('P1M');
$format = 'm-Y';
} else {
$interval = new DateInterval('P1W');
$format = 'W-Y';
}
if($startDateTime->format($format) == $endDateTime->format($format)) {
var_dump($startDateTime->format($format));
return;
}
$endDateTime->add($interval);
var_dump($endDateTime);
while($startDateTime <= $endDateTime){
var_dump($startDateTime->format("d-".$format));
$startDateTime->add($interval);
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.5.14 - 5.5.38 , 5.6.0 - 5.6.40 , 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.31 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.12 , 8.0.14 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 object(DateTime)#2 (3) {
["date"]=>
string(26) "2016-03-02 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
string(10) "01-01-2016"
string(10) "01-02-2016"
string(10) "01-03-2016"
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
object(DateTime)#2 (3) {
["date"]=>
string(26) "2016-03-02 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
string(10) "01-01-2016"
string(10) "01-02-2016"
string(10) "01-03-2016"
Output for 7.3.32 - 7.3.33 , 8.0.13 object(DateTime)#2 (3) {
["date"]=>
string(26) "2016-03-02 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
string(10) "01-01-2016"
string(10) "01-02-2016"
string(10) "01-03-2016"
Output for 5.5.0 - 5.5.13 object(DateTime)#2 (3) {
["date"]=>
string(19) "2016-03-02 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
string(10) "01-01-2016"
string(10) "01-02-2016"
string(10) "01-03-2016"
preferences:dark mode live preview
281.17 ms | 402 KiB | 329 Q