note 37832 deleted from function.checkdate by aidan

From: Date: Thu, 10 Feb 2005 05:30:46 +0000
Subject: note 37832 deleted from function.checkdate by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-84759@lists.php.net to get a copy of this message
Note Submitter: carsten at buy-hp dot dk ---- Example for count days between 2 dates. <?php $start = "20030101"; $end = "20031231"; function check($x){ return (strlen($x)==1?"0".$x:$x); } $count=0; for($i = $start;$i<=$end;$i++){ $year = substr($i,0,4); $mnd = substr($i,4,2); $day = substr($i,6,2); if(checkdate ($mnd,$day,$year)){ $count++; }else{ if($mnd>12){ $mnd = "01"; $day = "00"; $year++; } if($day>=31){ $day = "00"; $mnd = check($mnd+1); } $i = $year.$mnd.$day; } } echo $count; ?>

« previous php.notes (#84759) next »