@ 2017-09-12T12:06:32Z <?php
$get_st_date = "2017-09-01";
$get_end_date = "2017-09-20";
//Convert them to approprariate format to be used with DatePeriod
$get_begin = new DateTime( "$get_st_date" );
$get_end = new DateTime( "$get_end_date");
//Add an extra day or else it will be omitted from the following process.
$get_end = $get_end->add(new DateInterval('P1D'));
//Count per day
$get_interval = DateInterval::createFromDateString('1 day');
$get_period = new DatePeriod($get_begin, $get_interval, $get_end);
$e_d_w_p_w = "Monday;Tuesday;";
$workDays = [];
//Iteration Count
$iter = 0;
foreach($get_period as $get_dt) {
//Find if date is Saturday or Sunday. If it is, break that current loop.
$iter++;
$str_result = $get_dt->format('l');
if($str_result == "Saturday") {continue;}
elseif($str_result == "Sunday") {continue;}
elseif(preg_match("($str_result)", $e_d_w_p_w)){
$workDays[] = $get_dt;
}
}
var_dump($workDays);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.2.0 - 8.2.19 , 8.3.0 - 8.3.7 array(6) {
[0]=>
object(DateTime)#9 (3) {
["date"]=>
string(26) "2017-09-04 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[1]=>
object(DateTime)#11 (3) {
["date"]=>
string(26) "2017-09-05 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[2]=>
object(DateTime)#13 (3) {
["date"]=>
string(26) "2017-09-11 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[3]=>
object(DateTime)#10 (3) {
["date"]=>
string(26) "2017-09-12 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[4]=>
object(DateTime)#15 (3) {
["date"]=>
string(26) "2017-09-18 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[5]=>
object(DateTime)#12 (3) {
["date"]=>
string(26) "2017-09-19 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
}
Output for 5.4.30 - 5.4.45 , 5.5.14 - 5.5.38 , 5.6.0 - 5.6.38 , 7.0.0 - 7.0.31 , 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 array(6) {
[0]=>
object(DateTime)#7 (3) {
["date"]=>
string(26) "2017-09-04 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[1]=>
object(DateTime)#6 (3) {
["date"]=>
string(26) "2017-09-05 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[2]=>
object(DateTime)#9 (3) {
["date"]=>
string(26) "2017-09-11 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[3]=>
object(DateTime)#8 (3) {
["date"]=>
string(26) "2017-09-12 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[4]=>
object(DateTime)#11 (3) {
["date"]=>
string(26) "2017-09-18 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[5]=>
object(DateTime)#10 (3) {
["date"]=>
string(26) "2017-09-19 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
}
Output for 7.3.32 - 7.3.33 , 8.0.13 array(6) {
[0]=>
object(DateTime)#7 (3) {
["date"]=>
string(26) "2017-09-04 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
[1]=>
object(DateTime)#6 (3) {
["date"]=>
string(26) "2017-09-05 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
[2]=>
object(DateTime)#9 (3) {
["date"]=>
string(26) "2017-09-11 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
[3]=>
object(DateTime)#8 (3) {
["date"]=>
string(26) "2017-09-12 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
[4]=>
object(DateTime)#11 (3) {
["date"]=>
string(26) "2017-09-18 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
[5]=>
object(DateTime)#10 (3) {
["date"]=>
string(26) "2017-09-19 00:00:00.000000"
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
}
Output for 5.4.0 - 5.4.29 , 5.5.0 - 5.5.13 array(6) {
[0]=>
object(DateTime)#7 (3) {
["date"]=>
string(19) "2017-09-04 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[1]=>
object(DateTime)#6 (3) {
["date"]=>
string(19) "2017-09-05 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[2]=>
object(DateTime)#9 (3) {
["date"]=>
string(19) "2017-09-11 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[3]=>
object(DateTime)#8 (3) {
["date"]=>
string(19) "2017-09-12 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[4]=>
object(DateTime)#11 (3) {
["date"]=>
string(19) "2017-09-18 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
[5]=>
object(DateTime)#10 (3) {
["date"]=>
string(19) "2017-09-19 00:00:00"
["timezone_type"]=>
int(3)
["timezone"]=>
string(16) "Europe/Amsterdam"
}
}
Output for 4.4.2 - 4.4.9 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 , 5.3.0 - 5.3.29 Parse error: syntax error, unexpected '[' in /in/0TFE1 on line 15
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 , 5.0.0 - 5.0.5 Parse error: parse error, unexpected '[' in /in/0TFE1 on line 15
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error in /in/0TFE1 on line 15
Process exited with code 255 . preferences:dark mode live preview
243.44 ms | 401 KiB | 450 Q