note 116623 added to function.date-diff

From: Date: Fri, 30 Jan 2015 12:09:26 +0000
Subject: note 116623 added to function.date-diff
Groups: php.notes 
Request: Send a blank email to php-notes+get-201563@lists.php.net to get a copy of this message
This function will return count of sunday between inputed dates. <?php function CountSunday($from,$to) { $from=date('d-m-Y',strtotime($from)); $to=date('d-m-Y',strtotime($to)); $cnt=0; $nodays=(strtotime($to) - strtotime($from))/ (60 * 60 * 24); //it will count no. of days $nodays=$nodays+1; for($i=0;$i<$nodays;$i++) { $p=0; list($d, $m, $y) = explode("-",$from); $datetime = strtotime("$d-$m-$y"); $nextday = date('d-m-Y',strtotime("+1 day", $datetime)); //this will add one day in from date (from date + 1) if($i==0) $p=date('w',strtotime($from)); else $p=date('w',strtotime($nextday)); if($p==0) // check whethere value is 0 then its sunday $cnt++; //count variable of sunday $from=$nextday; $p++; } return $cnt; } ?> ---- Server IP: 72.52.91.14 Probable Submitter: 150.107.101.195 ---- Manual Page -- http://php.net/manual/en/function.date-diff.php Edit -- https://master.php.net/note/edit/116623 Del: integrated -- https://master.php.net/note/delete/116623/integrated Del: useless -- https://master.php.net/note/delete/116623/useless Del: bad code -- https://master.php.net/note/delete/116623/bad+code Del: spam -- https://master.php.net/note/delete/116623/spam Del: non-english -- https://master.php.net/note/delete/116623/non-english Del: in docs -- https://master.php.net/note/delete/116623/in+docs Del: other reasons-- https://master.php.net/note/delete/116623 Reject -- https://master.php.net/note/reject/116623 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201563) next »