Last active
November 17, 2020 09:24
-
-
Save ademalp/0f3f272f10045fa2ca171cfa8e199865 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function time_count($step, $start = "00:00", $end = "24:00", $except = array()){ | |
$start = strtotime($start); | |
$end = strtotime($end); | |
$next = $start; | |
$results = array(); | |
while($next < $end){ | |
$time = date("H:i", $next); | |
if(!in_array($time, $except)){ | |
$results[] = $time; | |
} | |
$next = strtotime("+$step minutes", $next); | |
} | |
return $results; | |
} | |
$except = time_count(20, "12:00", "13:00"); | |
$res = time_count(20, "09:00", "17:00", $except); | |
var_export($res); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
array (
0 => '09:00',
1 => '09:20',
2 => '09:40',
3 => '10:00',
4 => '10:20',
5 => '10:40',
6 => '11:00',
7 => '11:20',
8 => '11:40',
9 => '13:00',
10 => '13:20',
11 => '13:40',
12 => '14:00',
13 => '14:20',
14 => '14:40',
15 => '15:00',
16 => '15:20',
17 => '15:40',
18 => '16:00',
19 => '16:20',
20 => '16:40',
)