note 107555 added to function.date-diff
| From: | maniarpratikatgmaildotcom | Date: | Fri, 17 Feb 2012 09:34:26 +0000 |
| Subject: | note 107555 added to function.date-diff | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186185@lists.php.net to get a copy of this message | ||
This function will useful for counting sunday between two dates.
I had used here native functions of PHP
function CountSunday($from,$to)
{
$from=date('d-m-Y',strtotime($from)); //convert to format 'd-m-Y' for Example
(18-04-1989)
$to=date('d-m-Y',strtotime($to)); //convert to format 'd-m-Y' for Example
(18-05-1989)
$cnt=0; //used for count sunday
$nodays=(strtotime($to) - strtotime($from))/ (60 * 60 * 24); // Count total no.s of days between
inputed dates
$nodays=$nodays+1; //add one extra day for exact counting
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)); //Add one
day in from date
if($i==0)
$p=date('w',strtotime($from)); //it will return which day in numeric form
from , from date
else
$p=date('w',strtotime($nextday));//it will return which day in numeric
form from , nextday
if($p==0)
$cnt++;
$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/107555
Del: integrated -- https://master.php.net/note/delete/107555/integrated
Del: useless -- https://master.php.net/note/delete/107555/useless
Del: bad code -- https://master.php.net/note/delete/107555/bad+code
Del: spam -- https://master.php.net/note/delete/107555/spam
Del: non-english -- https://master.php.net/note/delete/107555/non-english
Del: in docs -- https://master.php.net/note/delete/107555/in+docs
Del: other reasons-- https://master.php.net/note/delete/107555
Reject -- https://master.php.net/note/reject/107555
Search -- https://master.php.net/manage/user-notes.php