note 107587 added to function.date-diff
| From: | maniarpratikatgmaildotcom | Date: | Mon, 20 Feb 2012 10:07:26 +0000 |
| Subject: | note 107587 added to function.date-diff | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186232@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: 69.147.83.197
Probable Submitter: 202.47.118.198
----
Manual Page -- http://www.php.net/manual/en/function.date-diff.php
Edit -- https://master.php.net/note/edit/107587
Del: integrated -- https://master.php.net/note/delete/107587/integrated
Del: useless -- https://master.php.net/note/delete/107587/useless
Del: bad code -- https://master.php.net/note/delete/107587/bad+code
Del: spam -- https://master.php.net/note/delete/107587/spam
Del: non-english -- https://master.php.net/note/delete/107587/non-english
Del: in docs -- https://master.php.net/note/delete/107587/in+docs
Del: other reasons-- https://master.php.net/note/delete/107587
Reject -- https://master.php.net/note/reject/107587
Search -- https://master.php.net/manage/user-notes.php