<?php
$firstAvailableCount = 100;
$slice = 'monthly';
$countData = array();
$startDateTime = new DateTime("2016-01-07");
$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';
$startDateTime = DateTime::createFromFormat($format."-d",$startDateTime->format($format).-"1");
$endDateTime = DateTime::createFromFormat($format."-d",$endDateTime->format($format).-"1");
} else {
$interval = new DateInterval('P1W');
$format = 'W-Y';
}
var_dump($startDateTime);
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);
}
}
- Output for 5.6.28, 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 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.6
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 19:51:59.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)#4 (3) {
["date"]=>
string(26) "2016-01-01 18:51:59.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 7.0.6
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 13:22:34.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.0.5
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 09:24:42.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.0.4
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 21:31:09.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.0.3
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 22:55:11.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.0.2
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 05:08:21.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.0.1
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 08:15:35.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.0.0
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 10:08:53.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 5.6.21
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 16:17:41.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 5.6.20
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 08:26:34.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 5.6.19
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 05:39:24.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 5.6.18
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 14:36:29.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 5.6.17
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 02:08:45.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 5.6.16
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 10:58:09.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 5.6.15
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 11:47:27.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 5.6.14
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 17:30: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 5.6.13
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 18:09:04.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 5.6.12
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 08:38:03.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 5.6.11
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 15:04:11.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 5.6.10
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 17:10:03.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 5.6.9
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 22:36:02.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 5.6.8
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 07:06:11.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 5.5.35
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 02:15:37.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 5.5.34
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 10:40:24.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 5.5.33
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 08:38:13.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 5.5.32
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 18:33:03.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 5.5.31
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 05:17:36.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 5.5.30
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 13:39:34.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 5.5.29
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 08:26:45.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 5.5.28
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 11:56:36.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 5.5.27
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 13:35:11.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 5.5.26
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 19:50:42.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 5.5.25
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 03:16:02.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 5.5.24
- object(DateTime)#4 (3) {
["date"]=>
string(26) "2016-01-01 09:39:25.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"
preferences:
189.87 ms | 401 KiB | 184 Q