note 95014 added to function.date

From: Date: Wed, 09 Dec 2009 00:40:48 +0000
Subject: note 95014 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-163725@lists.php.net to get a copy of this message
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 />"; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 61.6.54.141 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/95014 Del: integrated -- https://master.php.net/note/delete/95014/integrated Del: useless -- https://master.php.net/note/delete/95014/useless Del: bad code -- https://master.php.net/note/delete/95014/bad+code Del: spam -- https://master.php.net/note/delete/95014/spam Del: non-english -- https://master.php.net/note/delete/95014/non-english Del: in docs -- https://master.php.net/note/delete/95014/in+docs Del: other reasons-- https://master.php.net/note/delete/95014 Reject -- https://master.php.net/note/reject/95014 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#163725) next »