-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.php
More file actions
31 lines (22 loc) · 681 Bytes
/
2.php
File metadata and controls
31 lines (22 loc) · 681 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
function betweenDays($start = null, $end = null) {
// cek jika parameter kosong
if($start == null || $end == null) {
echo "Parameter null";
exit();
}
// array kosong
$array = array();
// interval 1 hari
$interval = new DateInterval('P1D');
$realEnd = new DateTime($end);
$realEnd->add($interval);
$period = new DatePeriod(new DateTime($start), $interval, $realEnd);
// looping
foreach($period as $date) {
$array[] = $date->format('Y-m-d');
}
//return
return $array;
}
print_r(betweenDays('2019-01-01', '2019-01-10'));