Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

Between Two Dates day count and removed Sunday using php

<?php       
function getalldates($strtdate,$enddate){
    $array = array(); 

    $period = new DatePeriod(
        new DateTime($strtdate),
        new DateInterval('P1D'),
        new DateTime($enddate)
    );

    foreach ($period as $key => $value) {
        $Store = $value->format('Y-m-d'); 
        $unixTimestamp = strtotime($Store);
		$dayOfWeek = date("l", $unixTimestamp);
        if($dayOfWeek != "Sunday"){
        $array[] = $Store;    
        }
          
    }
    return count($array);
}
$fdate = "2022-02-01";
$ldate = "2022-02-28";
$c = getalldates($fdate,$ldate);
echo $c;
?>
 
PREVIOUS NEXT
Tagged: #Between #Two #Dates #day #count #removed #Sunday #php
ADD COMMENT
Topic
Name
6+4 =