note 95014 deleted from function.date by danbrown
| From: | danbrown@php.net | Date: | Wed, 09 Dec 2009 01:46:40 +0000 |
| Subject: | note 95014 deleted from function.date by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-163732@lists.php.net to get a copy of this message | ||
Note Submitter: zaizarul[at]yahoo[dot]com
----
thank to dulare, i combine his/her function that can test a specific date that in between 2 date
yyyy-mm-dd
<?PHP
function days_between($year, $month, $day)
{
//from date 2009-12-2 to date 2009-12-7
$fday = 2;
$fmonth = 12;
$fyear = 2009;
$tday = 7;
$tmonth = 12;
$tyear = 2009;
for ($d=$fday;$d<=abs((mktime ( 0, 0, 0, $fmonth, $fday, $fyear) - mktime ( 0, 0, 0, $tmonth,
$tday, $tyear))/(60*60*24));$d++){
if ( mktime (0,0,0,$fmonth,$fday+$d,$fyear) == mktime (0,0,0,$month,$day,$year) ){
//u also can return date
return(1);
}
}
}
//date to check, will return 1 when is true
echo days_between(2009, 12, 3);
?>
also try this to print out the date in between 2 date
<?PHP
function days_between($fyear, $fmonth, $fday, $tyear, $tmonth, $tday)
{
return abs((mktime ( 0, 0, 0, $fmonth, $fday, $fyear) - mktime ( 0, 0, 0, $tmonth, $tday,
$tyear))/(60*60*24));
}
//from date 2009-12-2 to date 2009-12-7
$fday = 2;
$fmonth = 12;
$fyear = 2009;
$tday = 7;
$tmonth = 12;
$tyear = 2009;
for ($d=$fday;$d<=days_between($fyear, $fmonth, $fday, $tyear, $tmonth, $tday);$d++){
//will print 2/3/4/5/6/7-12-2009
echo date ("Y-m-d", mktime (0,0,0,$fmonth,$fday+$d,$fyear))."<br />";
}
?>