<?php
function date_in_period($format, $start, $end, $skip = NULL){
$output = array();
$days = floor((strtotime($end) - strtotime($start))/86400);
for($i=0;$i<=$days;$i++){
$in_period = strtotime("+" . $i . " day", strtotime($start));
if(is_array($skip) and in_array(date("D",$in_period), $skip)){
continue;
}
array_push($output, date($format, $in_period));
}
return $output;
}
echo "No skipping : <br / >";
$date = date_in_period("D-d-m-Y", "2011-04-04", "2011-04-19");
foreach($date as $day){
echo $day . "<br / >";
}
echo "Total : " . count($date) . " days<br / >";
echo "<br / ><br / >Has skipping : <br / >";
$date = date_in_period("D-d-m-Y", "2011-04-04", "2011-04-19", array("Mon", "Tue", "Wed", "Thu", "Fri"));
foreach($date as $day){
echo $day . "<br / >";
}
echo "Total : " . count($date) . " days";
?>
ข้อมูลจากเว็บ thaicrate.com
ไม่มีความคิดเห็น:
แสดงความคิดเห็น